feat: insert 和update结束之后需要调用 query_item重新查一遍
This commit is contained in:
@@ -286,7 +286,7 @@ def create_model_service(
|
|||||||
# 提交事务(保存到数据库)
|
# 提交事务(保存到数据库)
|
||||||
await session.commit()
|
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:
|
if after_insert is not None:
|
||||||
await after_insert(insert_cls, row_dict, session)
|
await after_insert(insert_cls, row_dict, session)
|
||||||
@@ -361,7 +361,7 @@ def create_model_service(
|
|||||||
# 提交事务
|
# 提交事务
|
||||||
await session.commit()
|
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:
|
if after_update is not None:
|
||||||
await after_update(update_cls, row_dict, session)
|
await after_update(update_cls, row_dict, session)
|
||||||
|
|||||||
Reference in New Issue
Block a user