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

ESCAPE <expression> must not interpret Escape codes. #1638

Closed
manticore-projects opened this issue Sep 24, 2022 · 2 comments · Fixed by #1715
Closed

ESCAPE <expression> must not interpret Escape codes. #1638

manticore-projects opened this issue Sep 24, 2022 · 2 comments · Fixed by #1715
Assignees
Labels

Comments

@manticore-projects
Copy link
Contributor

manticore-projects commented Sep 24, 2022

ESCAPE <expression> must not interpret Escape codes.

-- fails
select case 
    when id_portfolio like '%\_1' escape '\' then '1'
    end;

-- works
select case 
    when id_portfolio like '%\_1'  then '1'
    end;

-- works
select *
from dual
where id_portfolio like '%\_1' escape '\';

Odd enough even GitHub Syntax highlighting gets confused?!

@manticore-projects
Copy link
Contributor Author

It gets stranger by the minute:

-- works
select case 
    when id_portfolio like '%\_1' escape '\\' then '1'
    end;

This works in JSQLParser but is invalid on oracle: "ORA-01425: escape character must be character string of length 1"

@manticore-projects
Copy link
Contributor Author

manticore-projects commented Oct 14, 2022

I understand better, what is going on: the sequence ESCAPE '\' collides with the <ESC> token defined in the Grammar.
In the result, the Escape Expression becomes <S_CHARLITERAL> = '\' then '1' (including the <ESC> Token).

A kind ofUNESCAPED CHAR LITERAL will also not work because the LONGEST MATCH is chosen over the shortest match.

@manticore-projects manticore-projects changed the title CASE WHEN has problem with LIKE ESCAPE ESCAPE <expression> must not interpret Escape codes. Oct 15, 2022
manticore-projects added a commit to manticore-projects/JSqlParser that referenced this issue Jan 15, 2023
- Enables `\` as escape character in String Literals (beside SQL:2016 compliant `'`)
- Default is OFF (since its not SQL:2016 compliant)
- Activate per Parser Feature
- Fixes JSQLParser#1638
- Fixes JSQLParser#1209
- Fixes JSQLParser#1173
- Fixes JSQLParser#1172
- Fixes JSQLParser#832
- Fixes JSQLParser#827
- Fixes JSQLParser#578

BREAKING-CHANGE: Backslash Escaping needs to be activated explicitly or else Backslash won't work as Escape Character.
wumpz pushed a commit that referenced this issue Jan 20, 2023
* refactor: Merge REPLACE into UPSERT

fixes #1706

* feat: `DROP TEMPORARY TABLE ...`

fixes #1712

* build: PMD compliance

* ci: Merge master

* feat: Configurable backslash `\` escaping

- Enables `\` as escape character in String Literals (beside SQL:2016 compliant `'`)
- Default is OFF (since its not SQL:2016 compliant)
- Activate per Parser Feature
- Fixes #1638
- Fixes #1209
- Fixes #1173
- Fixes #1172
- Fixes #832
- Fixes #827
- Fixes #578

BREAKING-CHANGE: Backslash Escaping needs to be activated explicitly or else Backslash won't work as Escape Character.

* style: Checkstyle

* style: remove dead code

* style: PMD compliance

* style: Checkstyle, unused import

* feat: allow `S_CHAR_LITERAL` to break lines

- fixes #875
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant