Skip to content

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

Closed

Description

@manticore-projects

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?!

Activity

  1. manticore-projects commented on Sep 24, 2022

    @manticore-projects
    ContributorAuthor

    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"

  2. manticore-projects commented on Oct 14, 2022

    @manticore-projects
    ContributorAuthor

    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.

  3. changed the title [-]CASE WHEN has problem with LIKE ESCAPE[/-] [+]ESCAPE <expression> must not interpret Escape codes.[/+] on Oct 15, 2022
  4. added a commit that references this issue on Jan 15, 2023
    9d79d4b
  5. added a commit that references this issue on Jan 20, 2023
    a00d77a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions