This happened while using sqlalchemy .
I used kwargs to get a list from def in python. append to the list in def. You didn't even assign any parameters to the list when calling def. During the call, additional values are added to the list as duplicates.
Below is an example. What is the cause of the phenomenon?
def test(a=None, b=None, c=None, filter_list=[]):
if a is not None:
filter_list.append(a == model.a)
if b is not None:
filter_list.append(b == model.b)
if c is not None:
filter_list.append(c == model.c)
query = db.session.query(model).filter(and_(*filter_list))
test(a='a', b='b', c='c')
## query value prediction > select * from model where a = %s and b = %s and c = %s
## query value result > select * from model where a = %s and b = %s and c = %s and a = %s and b = %s and c = %s and a = %s and b = %s and c = %s and a = %s and b = %s and c = %s