You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] JSQLParser 5.4-SNAPSHOT : RDBMS : SELECT without FROM silently drops GROUP BY / HAVING / WINDOW / QUALIFY / CONNECT BY / PREFERRING in toString() #2483
SELECT without a FROM clause parses fine (supported Standard SQL, see #1514), but PlainSelect.toString() silently drops every clause after the select items except WHERE / PREWHERE: GROUP BY, HAVING, WINDOW, QUALIFY, START WITH / CONNECT BY and PREFERRING are all stored on the AST yet disappear from the output. A parse -> toString -> reparse round trip silently rewrites the statement.
The StatementDeParser path already renders all of them (SelectDeParser prints the whole clause chain outside its getFromItem() != null block), so the two render paths disagree.
Root cause: PlainSelect.appendSelectBodyTo (src/main/java/net/sf/jsqlparser/statement/select/PlainSelect.java): the shared clause chain lives inside the fromItem != null branch, while the else // without from branch prints preWhere / where only.
SQL Example:
SELECT1GROUP BY1HAVING1=1SELECT1 QUALIFY 1=1SELECT1 WINDOW w AS (ORDER BY1)
SELECT1 START WITH 1=1 CONNECT BY LEVEL <=1SELECT1 PREFERRING HIGH 1
All five parse on current master (ad69ecc), and each toString() returns SELECT 1:
IN : SELECT 1 GROUP BY 1 HAVING 1=1
OUT: SELECT 1
IN : SELECT 1 WINDOW w AS (ORDER BY 1)
OUT: SELECT 1
IN : SELECT 1 START WITH 1 = 1 CONNECT BY LEVEL <= 1
OUT: SELECT 1
WHERE survives (SELECT 1 WHERE 1 = 1 renders correctly), which shows the asymmetry.
Activity
fix: keep all clauses when deparsing SELECT without FROM (JSQLParser#…
fix: keep all clauses when deparsing SELECT without FROM (#2483) (#2484)