How to correctly pass None value to bindparam in SQLAlchemy?

Viewed 16
  • python==3.8.6
  • sqlalchemy==1.4.37
  • flask-sqlalchemy==2.5.1

I'am trying to filter db objects using bindparam, e.g.

Model.filter(Model.name == bindparam("name"))

and if name=None the released query contains name = null condition that is always false

But the following expression released the correct query with name is null condition:

Model.filter(Model.name == None)

How to correctly pass None value to bindparam to achieve the desired result?

0 Answers
Related