-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rel.True
, rel.False
, rel.NotTrue
, rel.NotFalse
filters
#279
Comments
I have not seen anywhere in docs that writing All docs and samples usually refer when filtering using boolean columns for true values like |
Prepare test table: create table test
(
b_null bool
);
INSERT INTO test (b_null) VALUES (null);
INSERT INTO test (b_null) VALUES (true);
INSERT INTO test (b_null) VALUES (false); Select with SELECT COUNT(1) FROM test WHERE b_null != true; -- 1
SELECT COUNT(1) FROM test WHERE b_null IS NOT TRUE; -- 2
|
@qRoC thanks for the suggestion! I actually I'm not aware of this and never seen it used in other orm or programming language so far. could you give more research about this syntax support in other database (sqlite, mysql and mssql) and proposal to support them? |
This behavior defined in ISO SQL:1999:
Basic SQL comparison operators always return The mysql 8: SELECT NULL IS TRUE; -- 0
SELECT NULL IS FALSE; -- 0
SELECT NULL IS UNKNOWN; -- 1 sqllite3: SELECT NULL IS TRUE; -- 0
SELECT NULL IS FALSE; -- 0
SELECT NULL IS UNKNOWN; -- SQL error or missing database (no such column: UNKNOWN)
Yes, this method is used if the database does not support F571. |
Thanks for your research 👍 this proposal looks good to me, let me know if you want to work on this 😄 |
In PG correct way to generate boolean comparison via predicate
IS
, likeIS TRUE
,IS NOT TRUE
, etc.https://www.postgresql.org/docs/9.0/datatype-boolean.html
The text was updated successfully, but these errors were encountered: