Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request]Add support for ESCAPE keyword in LIKE clause parsing #540

Closed
mk3008 opened this issue Oct 3, 2024 · 0 comments · Fixed by #541
Closed

[Request]Add support for ESCAPE keyword in LIKE clause parsing #540

mk3008 opened this issue Oct 3, 2024 · 0 comments · Fixed by #541
Assignees
Labels
enhancement New feature or request

Comments

@mk3008
Copy link
Owner

mk3008 commented Oct 3, 2024

Description

The current SQL parser supports the LIKE clause, but it doesn't handle the ESCAPE keyword. In SQL, the ESCAPE keyword allows users to define a custom escape character for special symbols in pattern matching. This feature is important for parsing complex SQL queries that use custom escape characters in LIKE conditions.

Expected Behavior

The parser should correctly recognize and handle the ESCAPE keyword, allowing users to define custom escape characters in LIKE clauses.

Example1:default

WITH users AS (
  SELECT '30' as name
  UNION ALL
  SELECT '%30'
)
SELECT * FROM users WHERE name LIKE '%3%'

result

name
30
%30

Example2:escape

WITH users AS (
  SELECT '30' as name
  UNION ALL
  SELECT '%30'
)
SELECT * FROM users WHERE name LIKE '\%3%'

result

name
%30

Example3:escape custom

WITH users AS (
  SELECT '30' as name
  UNION ALL
  SELECT '%30'
)
SELECT * FROM users WHERE name LIKE 'x%3%' escape 'x'

result

name
%30

Tasks

Modify the parser to recognize and process the ESCAPE keyword.
Add test cases to validate LIKE clauses with the ESCAPE keyword.

References

https://www.postgresql.jp/document/16/html/functions-matching.html

@mk3008 mk3008 added the enhancement New feature or request label Oct 3, 2024
@mk3008 mk3008 self-assigned this Oct 3, 2024
@mk3008 mk3008 linked a pull request Oct 3, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant