diff --git a/common/src/common/db/models/storage.py b/common/src/common/db/models/storage.py index 85edf86..0cd7daf 100644 --- a/common/src/common/db/models/storage.py +++ b/common/src/common/db/models/storage.py @@ -10,6 +10,13 @@ from common.db.base import Base class StorageObjects(Base): __tablename__ = "storage_objects" + # Force SQLAlchemy to round-trip server-default columns (created_at, + # updated_at, ...) via a follow-up SELECT after INSERT. Without this, + # attributes populated by `server_default` stay unloaded on the ORM + # object and the next sync read (e.g. storage_payload in storage_api.py) + # triggers a lazy refresh through the async driver, which raises + # MissingGreenlet because the read happens outside an awaitable. + __mapper_args__ = {"eager_defaults": "auto"} __table_args__ = ( Index("fk_storage_created_by", "created_by"), Index("idx_storage_content_hash", "content_hash"),