Skip to content

fix LIKE ESCAPE with backslash - #2568

Open
AaryavGangrade wants to merge 3 commits into
AlaSQL:developfrom
AaryavGangrade:fix-1978-like-escape
Open

AaryavGangrade wants to merge 3 commits into
AlaSQL:developfrom
AaryavGangrade:fix-1978-like-escape

Conversation

@AaryavGangrade

Copy link
Copy Markdown

Thank you for the time you are putting into AlaSQL!

Fixes #1978.

Backslash was not working correctly as the ESCAPE character in LIKE expressions because the escape value could reach utils.like() as a two-character backslash representation.

This change normalizes that representation to a single backslash before processing the LIKE pattern.

Tests

  • Added regression tests in test/test1978.js
  • Verified backslash escaping with alasql.utils.like()
  • Verified the SQL LIKE ... ESCAPE '\\' reproduction from the issue
  • Existing LIKE tests in test/test366.js and test/test369.js pass

@mathiasrw

Copy link
Copy Markdown
Member

@AaryavGangrade Thank you for this.

Can you see if you can find a more generic solution? This only accounts for \\ but what about \\\ or \\\\?

@AaryavGangrade

Copy link
Copy Markdown
Author

yes @mathiasrw Ill look into that

@AaryavGangrade

Copy link
Copy Markdown
Author

Hi @mathiasrw I have pushed the code to make it generic
On a side note I noticed that patternCache keys only on pattern without the escape character if you want I can fix it in a separate PR.

@AaryavGangrade

Copy link
Copy Markdown
Author

@mathiasrw Actually I am new to this open source contribution
Is the commit successful? And what are the next steps

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.

ESCAPE character issue

2 participants