fix: correctly handle ESCAPE character in LIKE clause (#1978)#2492
Open
imsanupm wants to merge 2 commits intoAlaSQL:developfrom
Open
fix: correctly handle ESCAPE character in LIKE clause (#1978)#2492imsanupm wants to merge 2 commits intoAlaSQL:developfrom
imsanupm wants to merge 2 commits intoAlaSQL:developfrom
Conversation
ade9294 to
bb69937
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #1978
LIKE clause with backslash \ as ESCAPE character returned no results
instead of correctly filtering rows.
Root Cause
Two bugs in
alasql.utils.likeinsrc/15utility.js:Cache key didn't include escape character — when two queries
used the same pattern but different escape characters, the wrong
cached regex was reused, giving incorrect results.
Backslash as escape broke regex — when \ was used as escape,
the next character was appended as
'\' + nextCharwhich produceda broken regex pattern.
Changes
src/15utility.js— fixed cache key to include escape character,and used proper regex escaping for the literal character after escape
Tests
Verified Scenarios