Skip to content

Commit 23972e0

Browse files
committed
Fix
1 parent 61a7b9e commit 23972e0

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

flask_sql_pro/db.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,13 @@ def handle_ops(cls, key, val, opt_type="where"):
8989
if key.endswith(op):
9090
if opt_type == 'exclude':
9191
sql_op = exclude_mapping[op]
92+
_key = key.replace(op, '')
9293
if op == '__between':
93-
phrase = f"{key} {sql_op} :{filter_str}_between_1_{key} AND :{filter_str}_between_2_{key} AND"
94+
phrase = f"{_key} {sql_op} :{filter_str}_between_1_{key} AND :{filter_str}_between_2_{key} AND "
95+
elif op == '__isnull':
96+
phrase = f"{_key} {sql_op} AND "
9497
else:
95-
phrase = f"{key} {sql_op} :{filter_str}{key} AND"
98+
phrase = f"{_key} {sql_op} :{filter_str}{key} AND "
9699
return phrase
97100

98101
return f"{key} = :_where_{key} AND"
@@ -226,9 +229,9 @@ def execute_update(cls, tb_name, data, where, app=None, bind=None, commit=False,
226229
sql += "`%s`" % key + " = :" + key + ","
227230
sql = sql[0:-1]
228231

229-
data = cls.fullfilled_data(data, where)
232+
data = cls.fullfilled_data(data, where, exclude=exclude)
230233
sql = cls.set_where_phrase(sql, where)
231-
sql = cls.set_exclude_phrase(sql, exclude=exclude)
234+
sql = cls.set_exclude_phrase(sql, exclude)
232235
try:
233236
if app and bind:
234237
bind = cls.db.get_engine(app, bind=bind)
@@ -302,9 +305,8 @@ def execute_delete(cls, tb_name, where, logic=False, app=None, bind=None, commit
302305
if logic:
303306
sql = "UPDATE %s SET %s=1" % (tb_name, cls.logic_delete_flag)
304307
sql = cls.set_where_phrase(sql, where)
305-
where = cls.fullfilled_data({}, where)
306-
sql = cls.set_exclude_phrase(sql, exclude=exclude)
307-
308+
sql = cls.set_exclude_phrase(sql, exclude)
309+
where = cls.fullfilled_data({}, where, exclude=exclude)
308310
try:
309311
if app and bind:
310312
bind = cls.db.get_engine(app, bind=bind)

0 commit comments

Comments
 (0)