fix(gencode): 修复业务表更新后返回数据懒加载问题

确保更新业务表后重新获取完整数据,避免懒加载导致的MissingGreenlet错误
同时添加psycopg-binary依赖并修复jinja2模板导入去重问题
This commit is contained in:
zhangtao
2026-02-02 00:23:41 +08:00
parent f48124b023
commit 0078f6dfda
5 changed files with 2060 additions and 1984 deletions
@@ -275,6 +275,8 @@ class GenTableService:
try:
# 直接调用edit_gen_table方法,它会在内部处理排除嵌套字段的逻辑
result = await GenTableCRUD(auth).edit_gen_table(table_id, data)
if not result:
raise CustomException(msg="更新业务表信息失败")
# 处理data.columns为None的情况
if data.columns:
@@ -285,7 +287,9 @@ class GenTableService:
await GenTableColumnCRUD(auth).update_gen_table_column_crud(
gen_table_column.id, column_schema
)
return GenTableOutSchema.model_validate(result).model_dump()
# 重新获取带有预加载关系的对象,避免懒加载导致的MissingGreenlet错误
updated_gen_table = await GenTableCRUD(auth).get_gen_table_by_id(table_id)
return GenTableOutSchema.model_validate(updated_gen_table).model_dump()
except Exception as e:
raise CustomException(msg=str(e))
else: