diff --git a/backend/plugin/code_generator/api/v1/code.py b/backend/plugin/code_generator/api/v1/code.py index 69c8e026..a58c0b6b 100644 --- a/backend/plugin/code_generator/api/v1/code.py +++ b/backend/plugin/code_generator/api/v1/code.py @@ -19,7 +19,7 @@ router = APIRouter() @router.get('/tables', summary='获取数据库表') async def get_all_tables( table_schema: Annotated[str, Query(description='数据库名')] = 'fba', -) -> ResponseSchemaModel[list[dict[str, str]]]: +) -> ResponseSchemaModel[list[dict[str, str | None]]]: data = await gen_service.get_tables(table_schema=table_schema) return response_base.success(data=data) diff --git a/backend/plugin/code_generator/crud/crud_code.py b/backend/plugin/code_generator/crud/crud_code.py index a756cfc9..6b695240 100644 --- a/backend/plugin/code_generator/crud/crud_code.py +++ b/backend/plugin/code_generator/crud/crud_code.py @@ -27,6 +27,7 @@ class CRUDGen: WHERE table_name NOT LIKE 'sys_gen_%' AND table_schema = :table_schema; """ + stmt = text(sql).bindparams(table_schema=table_schema) else: sql = """ SELECT c.relname AS table_name, obj_description(c.oid) AS table_comment @@ -36,7 +37,7 @@ class CRUDGen: AND n.nspname = 'public' -- schema 通常是 'public' AND c.relname NOT LIKE 'sys_gen_%'; """ - stmt = text(sql).bindparams(table_schema=table_schema) + stmt = text(sql) result = await db.execute(stmt) return result.mappings().all() @@ -63,6 +64,7 @@ class CRUDGen: LEFT JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind = 'r' AND n.nspname = 'public' -- schema 通常是 'public' + AND c.relname = :table_name AND c.relname NOT LIKE 'sys_gen_%'; """ stmt = text(sql).bindparams(table_name=table_name)