all_filters = [UserModal.role == 'admin']
if user.last_name:
all_filters.append(UserModal.last_name == 'Deo')
db.session.query(
UserModal.username
).filter(
**all_filters
).all()
In the code snippet, we are applying two filters on UserModel. First filter [UserModal.role == 'admin'] will be applied every time. But the second filter 'UserModal.last_name == 'Deo' will be applied if it will satisfy the condition user.last_name.
This article has incorrect information. ** is used to unpack dict. * is used to unpack arrays. Please fix the article.
Wrong Information