Failing SQL Feature:
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:
SELECT 1 GROUP BY 1 HAVING 1 = 1
SELECT 1 QUALIFY 1 = 1
SELECT 1 WINDOW w AS (ORDER BY 1)
SELECT 1 START WITH 1 = 1 CONNECT BY LEVEL <= 1
SELECT 1 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.
Software Information:
- JSqlParser 5.4-SNAPSHOT, master
ad69ecc
- JDK 17
- any RDBMS (renderer-level, dialect independent)
Failing SQL Feature:
SELECTwithout aFROMclause parses fine (supported Standard SQL, see #1514), butPlainSelect.toString()silently drops every clause after the select items exceptWHERE/PREWHERE:GROUP BY,HAVING,WINDOW,QUALIFY,START WITH/CONNECT BYandPREFERRINGare all stored on the AST yet disappear from the output. A parse -> toString -> reparse round trip silently rewrites the statement.The
StatementDeParserpath already renders all of them (SelectDeParserprints the whole clause chain outside itsgetFromItem() != nullblock), 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 thefromItem != nullbranch, while theelse // without frombranch printspreWhere/whereonly.SQL Example:
All five parse on current master (
ad69ecc), and eachtoString()returnsSELECT 1:WHEREsurvives (SELECT 1 WHERE 1 = 1renders correctly), which shows the asymmetry.Software Information:
ad69ecc