feat: insert 和update结束之后需要调用 query_item重新查一遍

This commit is contained in:
martsforever
2025-08-23 09:34:46 +08:00
parent 99c21f7e52
commit 9b349c7dcf
+2 -2
View File
@@ -286,7 +286,7 @@ def create_model_service(
# 提交事务(保存到数据库)
await session.commit()
# 刷新实例,获取数据库生成的最新数据(如自动更新的时间字段)
await session.refresh(insert_cls)
insert_cls = await self.query_item(session, {"id": insert_cls.id})
if after_insert is not None:
await after_insert(insert_cls, row_dict, session)
@@ -361,7 +361,7 @@ def create_model_service(
# 提交事务
await session.commit()
# 刷新实例,获取最新数据
await session.refresh(update_cls)
update_cls = await self.query_item(session, {"id": update_cls.id})
if after_update is not None:
await after_update(update_cls, row_dict, session)