-
Notifications
You must be signed in to change notification settings - Fork 515
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 4441 PostgreSql Dialect auxilary CTE (#4493)
* add PostgreSql Dialect SqlInsertStmtMixin Add mixin to override tablesAvailable For insert statement check the parent auxillary with clause * Add fixture Auxillary with clause using insert populated by select * Include support for delete stmt with mixin Delete statements can reference CTE * Add fixture referencing cte from auxilary delete statement * add support for update statement reference cte from update statement * add fixture for update statement --------- Co-authored-by: griffio <griffio@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...otlin/app/cash/sqldelight/dialects/postgresql/grammar/mixins/SqlDeleteStmtLimitedMixin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package app.cash.sqldelight.dialects.postgresql.grammar.mixins | ||
|
||
import app.cash.sqldelight.dialects.postgresql.grammar.psi.PostgreSqlDeleteStmtLimited | ||
import com.alecstrong.sql.psi.core.psi.LazyQuery | ||
import com.alecstrong.sql.psi.core.psi.SqlWithClause | ||
import com.alecstrong.sql.psi.core.psi.SqlWithClauseAuxiliaryStmt | ||
import com.alecstrong.sql.psi.core.psi.impl.SqlDeleteStmtLimitedImpl | ||
import com.intellij.lang.ASTNode | ||
import com.intellij.psi.PsiElement | ||
|
||
internal abstract class SqlDeleteStmtLimitedMixin( | ||
node: ASTNode, | ||
) : SqlDeleteStmtLimitedImpl(node), PostgreSqlDeleteStmtLimited { | ||
|
||
override fun tablesAvailable(child: PsiElement): Collection<LazyQuery> { | ||
val tablesAvailable = super.tablesAvailable(child) | ||
val withClauseAuxiliaryStmts = parent as? SqlWithClauseAuxiliaryStmt ?: return tablesAvailable | ||
val withClause = withClauseAuxiliaryStmts.parent as SqlWithClause | ||
return tablesAvailable + withClause.tablesExposed() | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
.../main/kotlin/app/cash/sqldelight/dialects/postgresql/grammar/mixins/SqlInsertStmtMixin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package app.cash.sqldelight.dialects.postgresql.grammar.mixins | ||
|
||
import app.cash.sqldelight.dialects.postgresql.grammar.psi.PostgreSqlInsertStmt | ||
import com.alecstrong.sql.psi.core.psi.LazyQuery | ||
import com.alecstrong.sql.psi.core.psi.SqlWithClause | ||
import com.alecstrong.sql.psi.core.psi.SqlWithClauseAuxiliaryStmt | ||
import com.alecstrong.sql.psi.core.psi.impl.SqlInsertStmtImpl | ||
import com.intellij.lang.ASTNode | ||
import com.intellij.psi.PsiElement | ||
|
||
internal abstract class SqlInsertStmtMixin( | ||
node: ASTNode, | ||
) : SqlInsertStmtImpl(node), PostgreSqlInsertStmt { | ||
|
||
override fun tablesAvailable(child: PsiElement): Collection<LazyQuery> { | ||
val tablesAvailable = super.tablesAvailable(child) | ||
val withClauseAuxiliaryStmts = parent as? SqlWithClauseAuxiliaryStmt ?: return tablesAvailable | ||
val withClause = withClauseAuxiliaryStmts.parent as SqlWithClause | ||
return tablesAvailable + withClause.tablesExposed() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters