0

Like we know, sqlalchemy logic operator is and_, or_, in_, but Python built-in logic operator is and, or,in. Why sqlalchemy doesn't use those built-in operator directly?

Tiancheng Liu
  • 782
  • 2
  • 9
  • 22
  • The short answer: it cannot. You cannot override the behaviour of the boolean **operations**. – Ilja Everilä Feb 02 '18 at 20:14
  • @Ilja Everilä That's actually what I want to ask. I know we cannot override built-in operations. But what are different behavior between sqlalchemy operations and built-in operations? Do they do exactly same things? – Tiancheng Liu Feb 02 '18 at 20:25
  • See the prior answer for examples of why. They do a very different thing. SQLAlchemy produces (boolean) SQL expression objects that get compiled to SQL in the end. The fact that you cannot override the behaviour of Python's boolean operations and that they short circuit cause all sorts of funny effects when combined with SQLAlchemy objects. – Ilja Everilä Feb 02 '18 at 20:27

0 Answers0