Skip to content

<S_CHAR_LITERAL> wrongly matches the chars with ' #1172

Closed

Description

@ZhaoRuidong

Describe the bug

To Reproduce
Steps to reproduce the behavior:

  1. Example SQL
    SELECT A ALIA1, CASE WHEN B LIKE 'ABC\_%' ESCAPE '\' THEN 'DEF' ELSE 'CCCC' END AS OBJ_SUB_TYPE FROM TABLE2

Expected behavior
<S_CHAR_LITERAL> should match the [ '\' ] rather than [ '' THEN ']

System

  • Database you are using Oracle
  • Java Version 1.8
  • JSqlParser version 4.0

Activity

  1. ZhaoRuidong commented on Apr 22, 2021

    @ZhaoRuidong
    Author

    I'm confused to the explanation of ~["0"-"9","a"-"z","A"-"Z","'","-"] matches any single character that is not a digit. https://www.engr.mun.ca/~theo/JavaCC-Tutorial/javacc-tutorial.pdf mentioned in Chap 1.4.1

  2. wumpz commented on Apr 28, 2021

    @wumpz
    Member

    This is indeed an open problem of JSqlparser. Since we are supporting multiple databases the escaping of single quotes can be \' or ''. This leads unfortunately to this behavior.

    Until now I was not able to produce a better regular expression. One solution would be to make this processing either way optional like for instance bracket parsing. Then only one way would be successful and then a correction would be easier.

    I'm confused to the explanation of ~["0"-"9","a"-"z","A"-"Z","'","-"] matches any single character that is not a digit. https://www.engr.mun.ca/~theo/JavaCC-Tutorial/javacc-tutorial.pdf mentioned in Chap 1.4.1

    Additionally, I don't see the connection between your second question to this issue.

  3. added a commit that references this issue on Jan 15, 2023
    9d79d4b
  4. 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

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions