LIKE自动加%value%,空值跳过过滤条件

This commit is contained in:
Hermes Agent 2026-06-22 14:43:32 +08:00
parent 4abf30356e
commit 3cc3b86d7b
8 changed files with 7 additions and 1 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -131,7 +131,7 @@ class DBFilter(object):
return f"{fj['field']} {op}"
var = fj.get('var')
if var and not var in ns.keys():
if var and (not var in ns.keys() or ns[var] == '' or ns[var] is None):
return None
if 'const' in keys:
@ -141,6 +141,12 @@ class DBFilter(object):
sql = '%s %s ${%s}$' % (fj.get('field'), fj.get('op'), name)
return sql
# LIKE 自动加 %value%
if op == 'LIKE':
val = ns.get(var)
if val and not val.startswith('%'):
ns[var] = f'%{val}%'
sql = '%s %s ${%s}$' % (fj.get('field'), fj.get('op'), fj.get('var'))
return sql