Skip to content

Error while parsing literals with backslash #1209

Closed
@xccui

Description

@xccui

Describe the bug
Can't properly parse the statement when

  1. Backslash is the last character of a literal;
  2. The literal is not the last value of a sequence.

To Reproduce
Steps to reproduce the behavior:

  1. Example: CCJSqlParserUtil.parseStatements("""INSERT INTO "a"."b"("c", "d", "e") VALUES ('c c\', 'dd', 'ee\')""") (Kotlin)
  2. Exception:
net.sf.jsqlparser.JSQLParserException: Encountered unexpected token: "dd" <S_IDENTIFIER>
    at line 1, column 53.

Was expecting one of:

    "&"
    ")"
    ","
    "::"
    "<<"
    ">>"
    "COLLATE"
    "["
    "^"
    "|"
  1. Note that CCJSqlParserUtil.parseStatements("""INSERT INTO "a"."b"("c", "d", "e") VALUES ('c c', 'dd', 'ee\')""") won't trigger the exception.

Expected behavior

The literals 'c c\' and 'dd'should be properly parsed.

System

  • Database: Oracle
  • Kotlin Version: 1.4.21-release-IJ2020.2-1
  • Java Version: 1.8
  • JSqlParser version: 4.0

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