mirror of
https://github.com/velocitatem/cvfs.git
synced 2026-05-31 08:43:37 +00:00
Fix two critical backend bugs found during integration testing
- versions.py: eagerly load public_assets in create_branch and append_patches_to_version refresh queries; missing selectinload caused MissingGreenlet 500 on every branch creation - documents.py: null root_version_id before cascade delete to break the circular FK (cv_documents → cv_versions → cv_documents), which was causing IntegrityError on every document deletion https://claude.ai/code/session_017HGM9VPptZG52asT5pbL6Y
This commit is contained in:
@@ -99,6 +99,9 @@ async def delete_document(
|
||||
await session.execute(
|
||||
delete(PublicAsset).where(PublicAsset.version_id.in_(version_ids))
|
||||
)
|
||||
# Null root_version_id to break the circular FK before cascade
|
||||
doc.root_version_id = None
|
||||
await session.flush()
|
||||
await session.delete(doc)
|
||||
await session.commit()
|
||||
for key in artifact_keys:
|
||||
|
||||
@@ -78,7 +78,7 @@ async def create_branch(
|
||||
stmt_refresh = (
|
||||
select(CvVersion)
|
||||
.where(CvVersion.id == new_version.id)
|
||||
.options(selectinload(CvVersion.patches))
|
||||
.options(selectinload(CvVersion.patches), selectinload(CvVersion.public_assets))
|
||||
)
|
||||
result = await session.execute(stmt_refresh)
|
||||
return result.scalars().one()
|
||||
@@ -138,7 +138,7 @@ async def append_patches_to_version(
|
||||
stmt_refresh = (
|
||||
select(CvVersion)
|
||||
.where(CvVersion.id == version_id)
|
||||
.options(selectinload(CvVersion.patches))
|
||||
.options(selectinload(CvVersion.patches), selectinload(CvVersion.public_assets))
|
||||
)
|
||||
result = await session.execute(stmt_refresh)
|
||||
return result.scalars().one()
|
||||
|
||||
Reference in New Issue
Block a user