Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG] JSQLParser Version 4.9 : RDBMS Postgresql 14.2 : Using Named Notation #2058

Open
bigdream96 opened this issue Aug 12, 2024 · 1 comment

Comments

@bigdream96
Copy link

Failing SQL Feature:

When calling a PostgreSQL function, you can use the := operator by specifying the name of each argument.

  • The following error occurs when parsing:
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "(" "("
    at line 1, column 29.

Was expecting one of:

    "."
    "::"
    "["
    "^"
    <EOF>
    <ST_SEMICOLON>

        at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:39603) ~[jsqlparser-4.9.jar!/:na]
        at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:39427) ~[jsqlparser-4.9.jar!/:na]
        at net.sf.jsqlparser.parser.CCJSqlParser.Statement(CCJSqlParser.java:317) ~[jsqlparser-4.9.jar!/:na]
        at net.sf.jsqlparser.parser.CCJSqlParserUtil$1.call(CCJSqlParserUtil.java:339) ~[jsqlparser-4.9.jar!/:na]
        at net.sf.jsqlparser.parser.CCJSqlParserUtil$1.call(CCJSqlParserUtil.java:336) ~[jsqlparser-4.9.jar!/:na]
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[na:na]
        ... 1 common frames omitted

SQL Example:

  • Simplified Query Example, focusing on the failing feature
SELECT concat_lower_or_upper(a := 'Hello', uppercase := true, b := 'World');

Software Information:

  • JSQLParser 4.9
  • PostgreSQL 14.2

Tips:

Newer versions of Postgresql use =>, but you can still use := for backwards compatibility, so I think it should be possible to parse it.

https://www.postgresql.org/docs/current/sql-syntax-calling-funcs.html#SQL-SYNTAX-CALLING-FUNCS-NAMED

@manticore-projects
Copy link
Contributor

Greetings.

for named parameters, "=>" is pretty much the established and accepted standard and JSQLParser supports this and Postgres does too.

If you are interested in supporting this legacy Postgres behavior you would need to sponsor or provide an implementation (which does not deteriorate the performance too much -- adding more features to the grammar always comes at a cost unfortunately.)

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants