-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: cast numeric to boolean and
and/or
only has Null on one side
- Loading branch information
Showing
5 changed files
with
137 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
statement ok | ||
DROP TABLE IF EXISTS t | ||
|
||
statement ok | ||
CREATE TABLE t (k INT PRIMARY KEY null, a INT null, b INT null) | ||
|
||
statement ok | ||
INSERT INTO t VALUES (1, NULL, NULL), (2, NULL, 1), (3, 1, NULL), (4, 2, 0), (5, 3, 3) | ||
|
||
statement error (?s)1006.*divided by zero while evaluating function `divide\(3, 0\)` | ||
SELECT a <> 2 AND 3 / b = 1 FROM t ORDER BY k | ||
|
||
query I | ||
SELECT a FROM t WHERE a <> 2 AND 3 / b = 1 ORDER BY k | ||
---- | ||
3 | ||
|
||
statement error (?s)1006.*divided by zero while evaluating function `divide\(3, 0\)` | ||
SELECT a = 2 OR 3 / b = 1 FROM t ORDER BY k | ||
|
||
query I | ||
SELECT a FROM t WHERE a = 2 OR 3 / b = 1 ORDER BY k | ||
---- | ||
2 | ||
3 | ||
|
||
statement ok | ||
truncate table t | ||
|
||
statement ok | ||
INSERT INTO t VALUES (1, NULL, NULL), (2, NULL, 1), (3, 1, NULL), (4, 2, 1), (5, 3, 3) | ||
|
||
query T | ||
SELECT a <> 2 AND 3 / b = 1 FROM t ORDER BY k | ||
---- | ||
null | ||
false | ||
null | ||
false | ||
true | ||
|
||
query I | ||
SELECT a FROM t WHERE a <> 2 AND 3 / b = 1 ORDER BY k | ||
---- | ||
3 | ||
|
||
query T | ||
SELECT a = 2 OR 3 / b = 1 FROM t ORDER BY k | ||
---- | ||
null | ||
null | ||
null | ||
true | ||
true | ||
|
||
query I | ||
SELECT a FROM t WHERE a = 2 OR 3 / b = 1 ORDER BY k | ||
---- | ||
2 | ||
3 | ||
|
||
statement ok | ||
DROP TABLE IF EXISTS t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
query I | ||
SELECT 1 | ||
---- | ||
1 | ||
|
||
statement error | ||
SELECT x | ||
|
||
query T | ||
SELECT 'a' | ||
---- | ||
a | ||
|
||
query B | ||
SELECT NOT(1=1) | ||
---- | ||
false | ||
|
||
query B | ||
SELECT NOT(1::boolean) | ||
---- | ||
false | ||
|
||
query B | ||
SELECT TRUE | ||
---- | ||
true | ||
|
||
query B | ||
SELECT FALSE | ||
---- | ||
false | ||
|
||
query B | ||
SELECT NOT(TRUE) | ||
---- | ||
false | ||
|
||
# issue: https://github.com/sqlparser-rs/sqlparser-rs/issues/362 | ||
# query T | ||
# SELECT 'That\'s good.' | ||
# ---- | ||
# That's good. | ||
|
||
statement error | ||
SELECT * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters