Skip to content

fix(core): allow referencing never-update columns in ON CONFLICT DO UPDATE WHERE clause#1913

Open
cschanhniem wants to merge 1 commit into
kysely-org:masterfrom
cschanhniem:fix-onconflict-where-never-update-type
Open

fix(core): allow referencing never-update columns in ON CONFLICT DO UPDATE WHERE clause#1913
cschanhniem wants to merge 1 commit into
kysely-org:masterfrom
cschanhniem:fix-onconflict-where-never-update-type

Conversation

@cschanhniem

Copy link
Copy Markdown

Problem: When a column has its update type set to never (e.g. ColumnType<Date, never, Date>), the WHERE clause of onConflict(...).doUpdateSet(...).where(...) fails to offer that column as a reference.

Root cause: OnConflictDatabase wraps the table type in Updateable, which strips columns whose UpdateType is never. This is correct for the doUpdateSet parameter (you can't update those columns) but incorrect for the WHERE clause (you can still filter on them).

Fix: Introduced OnConflictDatabaseForWhere that preserves all columns for WHERE clause reference purposes.

Fixes #1409

…PDATE WHERE clause

When a column has its update type set to never (e.g. `ColumnType<Date, never, Date>`),
the WHERE clause of `onConflict(...).doUpdateSet(...).where(...)` failed to offer
that column as a reference because `OnConflictDatabase` wrapped the table type in
`Updateable`, which strips columns whose `UpdateType` is never.

Fixed by introducing `OnConflictDatabaseForWhere` that preserves all columns for
WHERE clause reference purposes while keeping `OnConflictDatabase` for the
`doUpdateSet` parameter (where filtering non-updateable columns is correct).

Closes kysely-org#1409
@vercel

vercel Bot commented Jun 19, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Kysely Team Team on Vercel.

A member of the Team first needs to authorize it.

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.

Unable to reference a column name whose update type is set to never in the where clause of onconflict callback of insert

1 participant