Skip to content

Postgres identifiers with double quotes not supported #1335

Closed
@raipc

Description

@raipc

Describe the bug
Postgres supports double-quotes in table in column name identifiers with CSV-escape syntax, but they are unable to parse using JSqlParser

To Reproduce
Steps to reproduce the behavior:

  1. Example SQL
-- CREATE TABLE "table""with""quotes" (
--   "column""with""quotes" varchar(64)
-- );

INSERT INTO "table""with""quotes" ("column""with""quotes")
VALUES ('1'), ('2'), ('3');

UPDATE "table""with""quotes" SET "column""with""quotes" = '1.0'  
WHERE "column""with""quotes" = '1';

SELECT "column""with""quotes" FROM  "table""with""quotes"
WHERE "column""with""quotes" IS NOT NULL;
  1. Parsing this SQL using JSqlParser with this statements
  2. Exception
net.sf.jsqlparser.JSQLParserException: Encountered unexpected token: "\"quotes\"" <S_QUOTED_IDENTIFIER>
    at line 1, column 26.

Was expecting one of:

    "("
    "SET"
    "VALUES"
    "WITH"
    <K_SELECT>


	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:215)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:203)
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "\"quotes\"" <S_QUOTED_IDENTIFIER>
    at line 1, column 26.

Was expecting one of:

    "("
    "SET"
    "VALUES"
    "WITH"
    <K_SELECT>

	at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:26917)
	at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:26753)
	at net.sf.jsqlparser.parser.CCJSqlParser.Insert(CCJSqlParser.java:2501)
	at net.sf.jsqlparser.parser.CCJSqlParser.SingleStatement(CCJSqlParser.java:159)
	at net.sf.jsqlparser.parser.CCJSqlParser.Statements(CCJSqlParser.java:547)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:213)
	... 26 more

Expected behavior
I expect JSqlParser to parse these statements and be able to process identifiers as unescaped ones.

System

  • Database you are using: Postgres 9.6.2
  • Java Version: 8.0.292-librca
  • JSqlParser version: 4.1

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