Skip to content

Support recursive CTE CYCLE clauses and share recursive clause rendering - #2566

Merged
manticore-projects merged 2 commits into
JSQLParser:masterfrom
minleejae:feat/postgresql-cte-cycle
Sep 11, 2026
Merged

Support recursive CTE CYCLE clauses and share recursive clause rendering#2566
manticore-projects merged 2 commits into
JSQLParser:masterfrom
minleejae:feat/postgresql-cte-cycle

Conversation

@minleejae

@minleejae minleejae commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Recursive queries using PostgreSQL CYCLE currently fail after the CTE body. Add WithCycleClause with ordered cycle columns, the mark and path column names, and optional TO/DEFAULT expressions. SEARCH followed by CYCLE, implicit Boolean defaults, multiple CTEs and quoted names are supported.

WithItem now shares SEARCH/CYCLE suffix rendering between its model output and SelectDeParser. Expression callbacks let custom deparsers visit the key and mark expressions. The select visitor adapter, table finder and validator traverse the new clause.

Validation:

  • Full Gradle check and Maven verify.
  • Roundtrip/AST tests for six clause variants, malformed clauses, multiple CTEs and custom expression visitors/deparsers.
  • Six recursive SEARCH/CYCLE variants executed against an actual cyclic graph on PostgreSQL 18.

Reference: PostgreSQL SELECT: WITH SEARCH/CYCLE.

@manticore-projects

Copy link
Copy Markdown
Contributor

Please resolve conflict.

@minleejae

Copy link
Copy Markdown
Contributor Author

@manticore-projects Resolved the conflict with master, preserving both CYCLE validation and the DML CTE fix. Gradle check and Maven verify pass.

@manticore-projects
manticore-projects merged commit eddb1fb into JSQLParser:master Sep 11, 2026
7 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants