Skip to content

Fix sqlite with recursive #5892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 21, 2025
Merged

Conversation

griffio
Copy link
Collaborator

@griffio griffio commented Aug 21, 2025

Fixes #5039 #5891

Fix Compiler Stackoverflow in app.cash.sqldelight.core.lang.util.SelectStmtUtil

  • Add check for when compoundSelectStmt is null and stop recursion
  • Add fixture tests taken from issue examples for syntax checking only
  • Checked local snapshot compiles on the issue examples provided
  • Add Compiler Interface test as Fixture tests are only checking syntax

  • CHANGELOG.md's "Unreleased" section has been updated, if applicable.

Add check for `compoundSelectStmt` is not null as the recursion will continue `withClause.withClauseAuxiliaryStmtList[index]
            .findChildOfType<SqlCompoundSelectStmt>()?.tablesObserved().orEmpty()`

Error

`
at com.alecstrong.sql.psi.core.psi.SqlTableReference.resolve(SqlTableReference.kt:24)
at com.alecstrong.sql.psi.core.psi.SqlTableReference.resolve(SqlTableReference.kt:11)
at app.cash.sqldelight.core.lang.util.SelectStmtUtilKt.tablesObserved(SelectStmtUtil.kt:27)
at app.cash.sqldelight.core.lang.util.SelectStmtUtilKt.referencedTables(SelectStmtUtil.kt:55)
`
Examples with ctw table aliases and cte table references
Add a compiler test to check that stackoverflow is not occurring when using CTE alias
@griffio griffio marked this pull request as ready for review August 21, 2025 14:10
@griffio griffio merged commit 23552c8 into sqldelight:master Aug 21, 2025
18 checks passed
@griffio griffio deleted the fix-sqlite-with-recursive branch August 21, 2025 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

StackOverflowError when compiling recursive query
2 participants