Repository navigation
SQLite: Support NOT GLOB and NOT MATCH - #3043
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3043 +/- ##
=======================================
Coverage 83.64% 83.65%
=======================================
Files 42 42
Lines 35833 35837 +4
Branches 35833 35837 +4
=======================================
+ Hits 29974 29980 +6
Misses 2418 2418
+ Partials 3441 3439 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
there's a precedence issue: SELECT 'a' NOT GLOB 'a' = 1
-- this PR: 'a' NOT GLOB ('a' = 1)
-- SQLite: ('a' NOT GLOB 'a') = 1 -- sqlite3 3.53.3 returns 0; the right-grouped form returns 1in SQLite's docs (https://www.sqlite.org/lang_expr.html#operators_and_parse_affecting_attributes), =, ==, <>, !=, IS [NOT] [DISTINCT FROM], BETWEEN, IN, MATCH, LIKE, REGEXP and #[test]
fn parse_negated_glob_and_match_binds_like_comparison() {
for (operator, expected) in [
("NOT GLOB", BinaryOperator::NotGlob),
("NOT MATCH", BinaryOperator::NotMatch),
] {
assert_eq!(
sqlite().verified_expr(&format!("a {operator} 'p' = 1")),
Expr::BinaryOp {
left: Box::new(Expr::BinaryOp {
left: Box::new(Expr::Identifier(Ident::new("a"))),
op: expected,
right: Box::new(Expr::Value(
(Value::SingleQuotedString("p".to_string())).with_empty_span()
)),
}),
op: BinaryOperator::Eq,
right: Box::new(Expr::value(number("1"))),
}
);
}
}GLOB / MATCH already have this problem on main a nit: NotGlob/NotMatch should be inserted at the end; otherwise, it will BinaryOperator's serialized versions. serde formats like bincode use the enum variant position as discriminant, so changing the order of variants breaks file compatibility. idk if this is important for this crate tho. |
|
@zommiommy the misgrouping comes from the preexistent I will fix the level in a separate PR from |
851a228 to
cc68a65
Compare
|
Thanks @zommiommy for the review, I will be merging this now. cc @alamb |
SQLiteDialectparsesa GLOB banda MATCH bbut rejects their negated forms, which SQLite accepts.The SQLite infix hook now also reads
NOT GLOBandNOT MATCHas the newBinaryOperator::NotGlobandBinaryOperator::NotMatch, at the precedence the plain operators already have.