Skip to content

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

Open
minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:feat/postgresql-cte-cycle
Open

Support recursive CTE CYCLE clauses and share recursive clause rendering#2566
minleejae wants to merge 1 commit 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.

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.

1 participant