Skip to content

SQLite: Parse the BETWEEN lower bound up to its AND - #2664

Merged
LucaCappelletti94 merged 4 commits into
mainfrom
sqlite-between-operand-precedence
Oct 25, 2026
Merged

LucaCappelletti94 merged 4 commits into
mainfrom
sqlite-between-operand-precedence

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

In SQLite, comparison operators, IS, LIKE, NOTNULL and BETWEEN share one precedence level (https://www.sqlite.org/lang_expr.html#operators_and_parse_affecting_attributes), so the lower bound of a BETWEEN extends up to the AND: SQLite 3.51.1 runs 2 BETWEEN 1 > 0 AND 3, 2 BETWEEN NULL IS NULL AND 3, 2 BETWEEN 'a' LIKE 'a' AND 3 and a nested BETWEEN as the lower bound. The SQLite dialect stopped the lower bound at the BETWEEN precedence and failed with Expected: AND, found: >.

A new dialect method, between_low_bound_precedence, defaults to the BETWEEN precedence, and SQLiteDialect returns the AND precedence instead. The upper bound is unchanged, so operators after it still apply to the whole BETWEEN. Tests check the parsed lower bound and these forms in SQLite, and the unchanged error in the generic dialect.

@LucaCappelletti94 LucaCappelletti94 added bug Something isn't working SQLite labels Oct 17, 2026
@codecov-commenter

codecov-commenter commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.21%. Comparing base (a9b10d0) to head (a77caa9).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2664   +/-   ##
=======================================
  Coverage   82.20%   82.21%           
=======================================
  Files          42       42           
  Lines       35314    35320    +6     
  Branches    35314    35320    +6     
=======================================
+ Hits        29029    29037    +8     
  Misses       2716     2716           
+ Partials     3569     3567    -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LucaCappelletti94
LucaCappelletti94 added this pull request to stack #2666 October 17, 2026 16:57
@LucaCappelletti94
LucaCappelletti94 force-pushed the sqlite-between-operand-precedence branch 10 times, most recently from d1029bf to ba3c121 Compare October 24, 2026 14:06
@LucaCappelletti94
LucaCappelletti94 force-pushed the sqlite-between-operand-precedence branch from ba3c121 to e9e3170 Compare October 24, 2026 14:25
@LucaCappelletti94
LucaCappelletti94 force-pushed the sqlite-between-operand-precedence branch from e9e3170 to a77caa9 Compare October 25, 2026 16:28
@LucaCappelletti94
LucaCappelletti94 added this pull request to the merge queue Oct 25, 2026
Merged via the queue into main with commit fcd2328 Oct 25, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working SQLite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants