Skip to content

JSqlParserQueryEnhancer produces invalid query that JSqlParser can't parse #3707

Closed
@edudar-chwy

Description

@edudar-chwy

While trying all options to solve an issue mentioned in #3706, I tried JSqlParser. It created a count query closer to what it should be—it understands DISTINCT, at least. However, the enhancer created an invalid query.

Original query:

SELECT DISTINCT a.*, b.b1
FROM TableA a
  JOIN TableB b ON ...
  LEFT JOIN TableC ON ...
WHERE ...
ORDER BY b.b1, a.a1, a.a2

Derived count query:

SELECT count(DISTINCT *)
FROM TableA a
  JOIN TableB b ON ...
  LEFT JOIN TableC ON ...
WHERE ...

The enhancer complains that The query you provided is not a valid SQL Query and that it Encountered unexpected token: "(" "(" at line 1, column 13. The DB (Postgres) also fails this query because it should say SELECT count(DISTINCT a.*) FROM ....

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions