Skip to content

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

Open
LucaCappelletti94 wants to merge 1 commit into
mainfrom
sqlite-between-operand-precedence
Open

LucaCappelletti94 wants to merge 1 commit 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

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.25%. Comparing base (1aabd12) to head (1dbf078).

Files with missing lines Patch % Lines
src/parser/mod.rs 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2664   +/-   ##
=======================================
  Coverage   81.25%   81.25%           
=======================================
  Files          42       42           
  Lines       33910    33916    +6     
  Branches    33910    33916    +6     
=======================================
+ Hits        27553    27560    +7     
  Misses       2792     2792           
+ Partials     3565     3564    -1     

☔ 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.

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.

2 participants