Skip to content

SQLite: Bind <, <=, > and >= tighter than = - #2678

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

LucaCappelletti94 wants to merge 1 commit into
mainfrom
sqlite-comparison-precedence

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

SQLite's operator table puts <, <=, > and >= one level above =, ==, <>, !=, IS, IN, LIKE and BETWEEN (https://www.sqlite.org/lang_expr.html#operators_and_parse_affecting_attributes). So a = b < c means a = (b < c): SQLite 3.51.1 evaluates SELECT 2 = 1 < 3 to 0, which only holds for 2 = (1 < 3). The SQLite dialect used a single level for all comparisons and parsed it as (a = b) < c.

SQLiteDialect now returns a separate precedence for <, <=, > and >=. Since the default table has no free value between = and the bitwise operators, the dialect overrides prec_value with the default levels shifted up by one above =. Other dialects are unchanged: PostgreSQL 16 and DuckDB 1.4.4 reject 2 = 1 < 3 outright, so there is no grouping to match there. Tests check the tree for each pairing, IN and BETWEEN against <, and that every other dialect still parses a = b < c as (a = b) < c.

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

codecov-commenter commented Oct 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.29%. Comparing base (ada8314) to head (ef09b11).

Files with missing lines Patch % Lines
src/dialect/sqlite.rs 95.65% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2678   +/-   ##
=======================================
  Coverage   81.28%   81.29%           
=======================================
  Files          42       42           
  Lines       33920    33943   +23     
  Branches    33920    33943   +23     
=======================================
+ Hits        27571    27593   +22     
- Misses       2785     2786    +1     
  Partials     3564     3564           

☔ 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-comparison-precedence branch from 922069d to ef09b11 Compare October 18, 2026 14:17
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