feat: 还是改成用session.refresh来更新实例对象
This commit is contained in:
@@ -286,7 +286,8 @@ def create_model_service(
|
||||
# 提交事务(保存到数据库)
|
||||
await session.commit()
|
||||
# 刷新实例,获取数据库生成的最新数据(如自动更新的时间字段)
|
||||
insert_cls = await self.query_item(session, {"id": insert_cls.id})
|
||||
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 +362,8 @@ def create_model_service(
|
||||
# 提交事务
|
||||
await session.commit()
|
||||
# 刷新实例,获取最新数据
|
||||
update_cls = await self.query_item(session, {"id": update_cls.id})
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user