Fix insert exposes columns to select when used as row source#750
Open
griffio wants to merge 6 commits intosqldelight:masterfrom
Open
Fix insert exposes columns to select when used as row source#750griffio wants to merge 6 commits intosqldelight:masterfrom
griffio wants to merge 6 commits intosqldelight:masterfrom
Conversation
When the select stmt has a parent insert stmt, the insert resultQuery is omitted expect when the resultQuery contains a single row table for triggers and upserts.
keepSingleRowTables is a filter
griffio
commented
Mar 26, 2026
| } | ||
|
|
||
| private fun keepSingleRowTables(queryResults: Collection<QueryResult>): Collection<QueryResult> { | ||
| return queryResults.filter { it.table is SingleRow } |
Contributor
Author
There was a problem hiding this comment.
include only inherited SingleRow tables that are trigger table rows and on conflict table rows.
Fix WHERE clause using invalid table column
Check invalid table column in WHERE clause
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #601
fixes sqldelight/sqldelight#6194
🦺 Attempt to fix exposed columns in SELECT when used as row source for INSERT,
inherited columns from Triggers and use by CONFLICT clauses are allowed.
Removes inherited parent
QueryResultfrom theSelectStmtMixinwhere the ultimate parent isSqlInsertStmtexcept If the inherited parent
QueryResultcontains anySingleRowused with triggers and upsert statements.Must fail with
destination_idis not foundMust fail
WHERE destination_idreferences invalid columnMust fail with
idis not found inSELECT, must allowON CONFLICT(id)Must succeed as the INSERT table
destinationis not visible from the SELECT row source.NOTE:
When updating
sql-psidependency in SqlDelight this test will fail,https://github.com/sqldelight/sqldelight/blob/master/dialects/postgresql/src/testFixtures/resources/fixtures_postgresql/cte-invalid-tables/failure.txt and will need to add
Sample.s line 18:7 - No column found with name actor_idSeparate issue
RETURNINGfails with<compound operator real>, <join operator real>, GROUP, HAVING, INDEXED, LIMIT, NOT, ON, ORDER, RETURNING, WHERE or WINDOW expected, got 'destination_id']related to sqldelight/sqldelight#4938 can be worked-around with
ON CONFLICT (destination_id) DO NOTHINGCHANGELOG.md's "Unreleased" section has been updated, if applicable.