From 981da3d1e5ddc2b65c60277fd74cacdb1382dbe4 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Wed, 24 Jun 2026 17:26:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20update=E6=A8=A1=E6=9D=BF=E7=A9=BA?= =?UTF-8?q?=E5=80=BC=E5=A4=84=E7=90=86=20-=20=E7=A9=BA=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E8=B7=B3=E8=BF=87=E9=AA=8C=E8=AF=81=E5=92=8C=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 空字符串/None/NaN/null字段从ns中删除(除id外) - 验证规则跳过空值(Update时空=未修改) - 避免sor.U()用空值覆盖现有数据 --- xls2ddl/tmpls.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/xls2ddl/tmpls.py b/xls2ddl/tmpls.py index 0b9f615..65e0e65 100644 --- a/xls2ddl/tmpls.py +++ b/xls2ddl/tmpls.py @@ -329,9 +329,12 @@ return { """ data_update_tmpl = """ ns = params_kw.copy() -for k,v in ns.items(): - if v == 'NaN' or v == 'null': - ns[k] = None +for k,v in list(ns.items()): + if v == 'NaN' or v == 'null' or v == '' or v is None: + if k != 'id': + del ns[k] + else: + ns[k] = None if v in ('NaN', 'null') else v {% if logined_userid %} userid = await get_user() if not userid: @@ -374,6 +377,9 @@ for _fname, _rules in _validation_rules.items(): \t_val = params_kw.get(_fname, '') \tif _val is None: _val = '' \t_val = str(_val) +\t# Update: skip validation if field is empty (not modified) +\tif not _val or _val.strip() == '': +\t\tcontinue \tfor _rule in _rules: \t\t_rt = _rule.get('type', '') \t\t_rm = _rule.get('message', _fname)