Repository navigation
Parse SQLite's IS and IS NOT operators - #2470
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2470 +/- ##
=======================================
Coverage 82.54% 82.55%
=======================================
Files 42 42
Lines 35556 35572 +16
Branches 35556 35572 +16
=======================================
+ Hits 29349 29365 +16
Misses 2672 2672
Partials 3535 3535 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
56279d2 to
437a771
Compare
437a771 to
2d8ba04
Compare
sabir-akhadov-localstack
left a comment
There was a problem hiding this comment.
One non-blocking comment inline.
| BinaryOperator::Is | ||
| }; | ||
| // SQLite parses `IS` at the same left-associative level as the | ||
| // comparison operators, see <https://www.sqlite.org/syntax/expr.html> |
There was a problem hiding this comment.
SQLite puts < <= > >= one level above =/IS (lang_expr.html, operator table), so a IS b < c is a IS (b < c) there while this yields (a IS b) < c; sqlite 3.46: SELECT 0 IS 1 < 2 -> 0. Same pre-existing lumping the crate does for a = b < c, so fine to leave, but the comment could say "same level as =" and link lang_expr.html rather than syntax/expr.html, which has no precedence info.
There was a problem hiding this comment.
The comment describes IS and IS NOT at the same precedence level as = and links SQLite’s operator table. The preexisting comparison-precedence limitation is handled separately in #2678.
b333bc0 to
c4a4c07
Compare
| { | ||
| let expr2 = self.parse_subexpr(precedence)?; | ||
| Ok(Expr::IsNotDistinctFrom(Box::new(expr), Box::new(expr2))) | ||
| } else if self.parse_keyword(Keyword::JSON) { |
There was a problem hiding this comment.
Lets move the supports_is_operator() branch up, right after IS [NOT] DISTINCT FROM. Currently:
#[test]
fn sqlite_is_json_function_operand() {
// SQLite has no `IS JSON` predicate; `json(...)` is a function call.
for sql in [
"SELECT a IS json('{}') FROM t",
"SELECT a IS NOT json('{}') FROM t",
] {
sqlite().verified_stmt(sql);
}
}
Failed:
SELECT a IS json('{}') FROM t: ParserError("Expected: end of statement, found: (")
There was a problem hiding this comment.
Done, and also catched some other little things. Thanks for the review!
e904fb6 to
2eb35f2
Compare
|
Thanks @s5dsn-eqee and @sabir-akhadov-localstack for your reviews, I will be merging this now. cc @alamb |
This PR adds support for SQLite accepts
ISandIS NOTbetween arbitrary expressions. Only SQLite supports them, as far as I can tell.