| 1 | | Looks like the issue is the priorities of operators in postgres: |
| 2 | | |
| 3 | | {{{ |
| 4 | | postgres=# select false and false or true; |
| 5 | | ?column? |
| 6 | | t |
| 7 | | }}} |
| 8 | | |
| 9 | | |
| 10 | | {{{ |
| 11 | | postgres=# select false and true or false; |
| 12 | | ?column? |
| 13 | | f |
| 14 | | }}} |
| 15 | | |
| 16 | | And I think we are expecting the same operation priority as python: |
| 17 | | |
| 18 | | {{{ |
| 19 | | >>> 1 & 0 | 1 |
| 20 | | <<< 1 |
| 21 | | >>> 1 & 1 | 0 |
| 22 | | <<< 1 |
| 23 | | }}} |
| 24 | | |
| 25 | | To make things simpler: in python OR operators (`|` and `or`) are evaluated before AND operators (`&` and `and`), while for postgres they have the same priority order. |
| 26 | | |
| 27 | | To solve this issue and similar ones, we might want to always add brackets around `OR` operator. |
| | 1 | [Retracting my comment] I though I fond something, but just got lost in my brackets count |