LIKE自动加%value%,空值跳过过滤条件
This commit is contained in:
parent
4abf30356e
commit
3cc3b86d7b
BIN
sqlor/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
sqlor/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
sqlor/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
sqlor/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
sqlor/__pycache__/dbpools.cpython-310.pyc
Normal file
BIN
sqlor/__pycache__/dbpools.cpython-310.pyc
Normal file
Binary file not shown.
BIN
sqlor/__pycache__/ddl_template_mysql.cpython-312.pyc
Normal file
BIN
sqlor/__pycache__/ddl_template_mysql.cpython-312.pyc
Normal file
Binary file not shown.
BIN
sqlor/__pycache__/ddl_template_oracle.cpython-312.pyc
Normal file
BIN
sqlor/__pycache__/ddl_template_oracle.cpython-312.pyc
Normal file
Binary file not shown.
BIN
sqlor/__pycache__/ddl_template_postgresql.cpython-312.pyc
Normal file
BIN
sqlor/__pycache__/ddl_template_postgresql.cpython-312.pyc
Normal file
Binary file not shown.
BIN
sqlor/__pycache__/ddl_template_sqlserver.cpython-312.pyc
Normal file
BIN
sqlor/__pycache__/ddl_template_sqlserver.cpython-312.pyc
Normal file
Binary file not shown.
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user