Replaced db.flush with db.commit

To try fix some odd cases of greenlet whining
This commit is contained in:
Donkie
2023-08-28 20:31:25 +02:00
parent e6b30da55d
commit 6e7d9a2e03
3 changed files with 9 additions and 9 deletions

View File

@@ -49,7 +49,7 @@ async def create(
color_hex=color_hex,
)
db.add(db_item)
await db.flush()
await db.commit()
return db_item
@@ -111,7 +111,7 @@ async def update(
filament.vendor = await vendor.get_by_id(db, v)
else:
setattr(filament, k, v)
await db.flush()
await db.commit()
return filament
@@ -120,7 +120,7 @@ async def delete(db: AsyncSession, filament_id: int) -> None:
filament = await get_by_id(db, filament_id)
await db.delete(filament)
try:
await db.flush() # Flush immediately so any errors are propagated in this request.
await db.commit() # Flush immediately so any errors are propagated in this request.
except IntegrityError as exc:
await db.rollback()
raise ItemDeleteError("Failed to delete filament.") from exc