Skip to content

fix: INSERT.from(SELECT) used non-existent value #1565

Open
patricebender wants to merge 7 commits into
mainfrom
fix/insert-from-select-managed-defaults
Open

fix: INSERT.from(SELECT) used non-existent value #1565
patricebender wants to merge 7 commits into
mainfrom
fix/insert-from-select-managed-defaults

Conversation

@patricebender
Copy link
Copy Markdown
Member

@patricebender patricebender commented Apr 9, 2026

referencing undefined value column

managed_default unconditionally emitted json_type(value, ...) to check whether a column value was provided. This only works in json_each() contexts used by INSERT.entries()/INSERT.rows(). For INSERT.from(SELECT), there is no json_each() because the source is a subquery aliased as NEW.

Now managed_default checks the INSERT context: for INSERT.from(SELECT), it uses src IS NULL instead of json_type(value, ...).

Closes #1559

…`value` column

`managed_default` unconditionally emitted `json_type(value, ...)` to check
whether a column value was provided. This only works in `json_each()` contexts
used by `INSERT.entries()`/`INSERT.rows()`. For `INSERT.from(SELECT)`, there
is no `json_each()` — the source is a subquery aliased as `NEW`.

Now `managed_default` checks the INSERT context: for `INSERT.from(SELECT)`,
it uses `src IS NULL` instead of `json_type(value, ...)`.

Closes #1559
@patricebender patricebender marked this pull request as draft April 9, 2026 14:05
@patricebender patricebender marked this pull request as ready for review April 9, 2026 14:14
@patricebender patricebender force-pushed the fix/insert-from-select-managed-defaults branch from 5eb83d4 to 19e1bbd Compare April 9, 2026 14:27
patricebender and others added 6 commits April 9, 2026 20:57
…`value` column

`managed_default` unconditionally emitted `json_type(value, ...)` to check
whether a column value was provided. This only works in `json_each()` contexts
used by `INSERT.entries()`/`INSERT.rows()`. For `INSERT.from(SELECT)`, there
is no `json_each()` — the source is a subquery aliased as `NEW`.

For columns not provided by the SELECT (added via `requiredColumns`), the
managed default is now applied directly. Columns that are in the SELECT pass
through verbatim — NULL is a valid provided value and must not be overridden.

Closes #1559
@patricebender
Copy link
Copy Markdown
Member Author

@BobdenOs is this PR ready?

@BobdenOs
Copy link
Copy Markdown
Contributor

@patricebender it is ready, but it now requires an additional reviewer.

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.

Problem with SQLite on INSERT.into...from when providing columns

2 participants