taozhi8833998 / node-sql-parser

Parse simple SQL statements into an abstract syntax tree (AST) with the visited tableList and convert it back to SQL
https://taozhi8833998.github.io/node-sql-parser/
Apache License 2.0
798 stars 180 forks source link

DISTINCT inside Postgres string_agg function throws #1894

Closed aligg73 closed 5 months ago

aligg73 commented 5 months ago

Describe the bug Using DISTINCT inside the string_agg function in PostgresQL, throws this error: SyntaxError]: Expected "(", "--", ".", "/*", or [ \t\n\r] but "t" found.

Database Engine PostgresQL

To Reproduce -the SQL that be parsed SELECT string_agg(DISTINCT title) FROM jobs;

-the node-sql-parser version 5.1.0

-the node version Node v18

Expected behavior I expect the query to be parsed as it is valid (Postgres)QL and works when querying the database.

Additional context Removing the DISTINCT within the string_agg function works, also 'normal' DISTINCT (outside string_agg function) works as well.