0

I want to run this SqlAlchemy query but the "or_" operator is not "short circuiting". For example, I want the result to be filtered by Car_Make="Toyota" or records which are not None. But the query result throws out all Toyotas and all not None records. I want it to filter either on Toyota and if no toyota then everything which is not None.

Searched_Cars = Cars.query.filter(or_(Cars.Car_Make=="Toyota", Cars.Car_Make !=None)).order_by(Cars.Date_Created.desc())

Any hints?

ARS
  • 1
  • 1
  • I think you want `== "Toyota"`. Also, you have a typo in "filter" – jordanm Feb 06 '18 at 00:00
  • There is no short circuiting OR in SQL: https://stackoverflow.com/questions/789231/is-the-sql-where-clause-short-circuit-evaluated. Effectively your query should fetch all non-null values. Please include some sample data, expected outputs, and your model. – Ilja Everilä Feb 06 '18 at 07:09

0 Answers0