Fix MissingGreenlet 500 error on GET /api/campaigns
Add selectinload(Campaign.agency) to get_with_proof_counts query so the agency relationship is eagerly loaded. Without it, accessing campaign.agency.name in the route triggered a lazy load in an async context, raising sqlalchemy.exc.MissingGreenlet and returning HTTP 500. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3a66286900
commit
46e7de5695
1 changed files with 1 additions and 0 deletions
|
|
@ -114,6 +114,7 @@ class CampaignRepository:
|
|||
func.count(Proof.id).label("proof_count"),
|
||||
)
|
||||
.outerjoin(Proof)
|
||||
.options(selectinload(Campaign.agency))
|
||||
.group_by(Campaign.id)
|
||||
)
|
||||
if agency_id:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue