Fix async SQLAlchemy MissingGreenlet error on campaign update

Refresh campaign object after flush to reload expired attributes
and relationships, preventing lazy load failures in async context.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
michael 2026-01-08 10:20:56 -06:00
parent 96d459c322
commit 37c2532263

View file

@ -90,6 +90,8 @@ class CampaignRepository:
setattr(campaign, key, value)
await self.session.flush()
# Refresh to reload expired attributes and relationships after flush
await self.session.refresh(campaign, ["agency", "proofs"])
return campaign
async def delete(self, campaign_id: uuid.UUID) -> bool: