fix: set escape_char when simplifying starts_with to LIKE#21086
Open
jackye1995 wants to merge 2 commits intoapache:mainfrom
Open
fix: set escape_char when simplifying starts_with to LIKE#21086jackye1995 wants to merge 2 commits intoapache:mainfrom
jackye1995 wants to merge 2 commits intoapache:mainfrom
Conversation
The `starts_with` simplification escapes special LIKE characters (%, _, \) with backslash but did not set escape_char in the resulting LIKE expression. This caused the escaped characters to be treated as literals instead of escape sequences. For example, `starts_with(col, 'test_ns')` was simplified to: `col LIKE 'test\_ns%'` with `escape_char: None` This meant the `\_` was not recognized as an escaped underscore, causing incorrect query results when the prefix contained special LIKE pattern characters. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
Summary
The
starts_withsimplification escapes special LIKE characters (%,_,\) with backslash but did not setescape_charin the resulting LIKE expression. This caused the escaped characters to be treated as literals instead of escape sequences.Problem
When
starts_with(col, 'test_ns')is simplified tocol LIKE 'test\_ns%', theescape_charwas set toNone. This meant the\_was not recognized as an escaped underscore, and the underscore was incorrectly interpreted as a LIKE wildcard matching any single character.Example
Fix
Set
escape_char: Some('\\')when creating the LIKE expression, since the simplification already uses backslash to escape special characters.Testing
starts_withtests pass🤖 Generated with Claude Code