Skip to content

Keep ESCAPE in the text of a LIKE expression - #2674

Merged
mathiasrw merged 1 commit into
developfrom
fix/like-escape-tostring
Oct 20, 2026
Merged

mathiasrw merged 1 commit into
developfrom
fix/like-escape-tostring

Conversation

@mathiasrw

Copy link
Copy Markdown
Member

toString() of a LIKE 'x!%' ESCAPE '!' dropped the ESCAPE part. The text of an expression is also its identity: aggregates are shared by it, and an unnamed column is named by it. So two expressions that differ only in ESCAPE were taken as one:

SELECT SUM(CASE WHEN s LIKE '%!%%' THEN 1 ELSE 0 END) AS x,
       SUM(CASE WHEN s LIKE '%!%%' ESCAPE '!' THEN 1 ELSE 0 END) AS y FROM ?
-- data: a%b, a!b, a!b. Was x = 2, y = 2; SQLite and now: x = 2, y = 1

Op.toString() now adds ESCAPE … when there is one. Test: test/test2568-C.js.

Found while reviewing #1197.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant