Repository navigation
SQLite: Support NOT GLOB and NOT MATCH - #3043
LucaCappelletti94 wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3043 +/- ##
=======================================
Coverage 83.56% 83.56%
=======================================
Files 42 42
Lines 35689 35693 +4
Branches 35689 35693 +4
=======================================
+ Hits 29822 29828 +6
Misses 2429 2429
+ Partials 3438 3436 -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 |
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.