fix: add refresh before assigning promo_groups to avoid async lazy load error

This commit is contained in:
c0mrade
2026-02-02 04:55:27 +03:00
parent cb0ccc9c77
commit 5e75210c8b

View File

@@ -233,6 +233,8 @@ async def create_tariff(
if promo_group_ids:
promo_groups_result = await db.execute(select(PromoGroup).where(PromoGroup.id.in_(promo_group_ids)))
promo_groups = promo_groups_result.scalars().all()
# Refresh чтобы избежать lazy load в async контексте
await db.refresh(tariff, ['allowed_promo_groups'])
tariff.allowed_promo_groups = list(promo_groups)
await db.commit()