Skip to content

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

Open
LucaCappelletti94 wants to merge 2 commits into
mainfrom
sqlite-between-operand-precedence
Open

LucaCappelletti94 wants to merge 2 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 81.53%. Comparing base (424378c) to head (46f4566).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2664   +/-   ##
=======================================
  Coverage   81.52%   81.53%           
=======================================
  Files          42       42           
  Lines       34205    34211    +6     
  Branches    34205    34211    +6     
=======================================
+ Hits        27885    27893    +8     
  Misses       2770     2770           
+ Partials     3550     3548    -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 force-pushed the sqlite-between-operand-precedence branch from 9f9b65e to 46f4566 Compare October 21, 2026 07:31
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