From 36267a18cc79c22eccc0b14a31c4e0a47a99a443 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Mon, 22 Jun 2026 13:40:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=BD=BF=E7=94=A8LIKE=E6=A8=A1=E7=B3=8A?= =?UTF-8?q?=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xls2ddl/tmpls.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/xls2ddl/tmpls.py b/xls2ddl/tmpls.py index 7251921..4824cb5 100644 --- a/xls2ddl/tmpls.py +++ b/xls2ddl/tmpls.py @@ -171,6 +171,17 @@ ori_fields = json.loads(fields_str) if not filterjson: fields = [ f['name'] for f in ori_fields ] filterjson = default_filterjson(fields, ns) + # 字符串字段使用LIKE模糊匹配 + str_fields = {f['name'] for f in ori_fields if f.get('type') in ('str', 'text')} + if filterjson and str_fields: + if not isinstance(filterjson, dict) or 'AND' not in filterjson: + filterjson = {'AND': [filterjson] if filterjson else []} + for fj in filterjson['AND']: + if fj.get('field') in str_fields and fj.get('op') == '=': + var = fj.get('var') + if var and var in ns and ns[var]: + ns[var] = f'%{ns[var]}%' + fj['op'] = 'LIKE' {% if logined_userorgid or logined_userid %} # 确保 logined 过滤条件始终生效 if filterjson: