Skip to content

Conversation

Arzaroth
Copy link
Contributor

@Arzaroth Arzaroth commented Feb 17, 2022

Impetus

This addresses the problem mentioned in issue #40484, while avoiding pitfalls brought up by issue #40757.
This PR was originally submitted as #40529, by reverted by #40791.

Changes

The problem with previous implementation was assuming that bitwise operators always produce an integer (or at least a number).

I failed to see that these operators (notably >> and <<) where not only bitwise arithmetic operators for PostgreSQL but also range operators (as described here).
In the issue #40757, we fall exactly in this case.

Thus, the approach I took this time was to force a cast to bool in PostgreSQL, which solves both the initial problem and ones caused by the previous implementation.

Since both MySQL and SQLite support "implicit casting" to boolean, it is essentially a noop for those grammars.

SQL Server still requires the "old trick" of != 0. The documentation states that it "converts the result to an integer.", so the comparison is safe.

@taylorotwell
Copy link
Member

@Arzaroth I can't edit your fork. Please grant me access or I can't merge this.

@taylorotwell
Copy link
Member

Put it here so I can edit it: #41112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants