mirror of
https://github.com/velocitatem/cvfs.git
synced 2026-05-31 08:43:37 +00:00
fix(db): ensure versions and patches are loaded when returning created document
This commit is contained in:
@@ -36,8 +36,15 @@ async def create_document(
|
|||||||
|
|
||||||
session.add(doc)
|
session.add(doc)
|
||||||
await session.commit()
|
await session.commit()
|
||||||
await session.refresh(doc, attribute_names=["versions"])
|
await session.refresh(doc)
|
||||||
return doc
|
|
||||||
|
stmt = (
|
||||||
|
select(CvDocument)
|
||||||
|
.where(CvDocument.id == doc.id)
|
||||||
|
.options(selectinload(CvDocument.versions).selectinload(CvVersion.patches))
|
||||||
|
)
|
||||||
|
result = await session.execute(stmt)
|
||||||
|
return result.scalars().unique().one()
|
||||||
|
|
||||||
|
|
||||||
async def list_documents(session: AsyncSession, owner_id: str) -> list[CvDocument]:
|
async def list_documents(session: AsyncSession, owner_id: str) -> list[CvDocument]:
|
||||||
|
|||||||
Reference in New Issue
Block a user