From b530cb95b77e3f79cdd0c36d1d5680c48a8041a3 Mon Sep 17 00:00:00 2001 From: martsforever Date: Tue, 14 Oct 2025 21:55:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=B9=E9=87=8F=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E4=B9=9F=E8=83=BD=E5=A4=9F=E6=94=AF=E6=8C=81=E6=8C=89=E9=9C=80?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/general/general_utils/sql_service.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/general/general_utils/sql_service.py b/app/general/general_utils/sql_service.py index 0537eeb..277e63f 100644 --- a/app/general/general_utils/sql_service.py +++ b/app/general/general_utils/sql_service.py @@ -203,16 +203,12 @@ async def update(session: AsyncSessionDep, query_config, module_config, debug_da row = get_value(query_config, 'row', None) update_by_fields = get_value(query_config, 'updateByFields', env.default_update_by_fields) - update_fields = get_value(query_config, 'updateFields', None) if row is None: return { "error": "row parameter is missing", } - if not update_fields and update_by_fields: - update_fields = row.keys() - row_id = get_value(row, 'id', None) if row_id is None: @@ -223,7 +219,7 @@ async def update(session: AsyncSessionDep, query_config, module_config, debug_da create_convertor(module_config)['encode_list']([row]) try: - sql, values = build_update_sql(module_config, row, update_fields) + sql, values = build_update_sql(module_config, row, row.keys() if update_by_fields else None) debug_data.append({"sql": sql, "values": values}) await conn.exec_driver_sql(sql, tuple(values)) @@ -257,7 +253,7 @@ async def batch_update(session: AsyncSessionDep, query_config, module_config, de conn = await session.connection() rows = get_value(query_config, 'rows', None) - update_fields = get_value(query_config, 'updateFields', None) + update_by_fields = get_value(query_config, 'updateByFields', env.default_update_by_fields) if rows is None or len(rows) == 0: return { @@ -274,7 +270,7 @@ async def batch_update(session: AsyncSessionDep, query_config, module_config, de try: for row in rows: - sql, values = build_update_sql(module_config, row, update_fields) + sql, values = build_update_sql(module_config, row, row.keys() if update_by_fields else None) debug_data.append({"sql": sql, "values": values}) await conn.exec_driver_sql(sql, tuple(values))