Skip to content

fix: use undefined check to avoid crash when set[colName] is null #4709

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

Open
wants to merge 2 commits into
base: beta
Choose a base branch
from

Conversation

aleclarson
Copy link

@aleclarson aleclarson commented Jul 4, 2025

This bug is related to the buildUpdateSet method in each Dialect class.

This filters columns so that only those defined in set or with an onUpdateFn are used:

const columnNames = Object.keys(tableColumns).filter((colName) =>
set[colName] !== undefined || tableColumns[colName]?.onUpdateFn !== undefined
);

While this erroneous check uses ?? which accidentally "skips" null when it shouldn't, resulting in a crash if the column has no onUpdateFn (or incorrect behavior if it does have an onUpdateFn):

const value = set[colName] ?? sql.param(col.onUpdateFn!(), col);

@aleclarson aleclarson force-pushed the fix/bad-nullish-coalescing-operator branch from 1d52d59 to 109ccd3 Compare July 4, 2025 23:37
@aleclarson aleclarson changed the title fix(sqlite): use undefined check to avoid crash when set[colName] is null fix: use undefined check to avoid crash when set[colName] is null Jul 4, 2025
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.

1 participant