mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
Previously, the sql() helper would convert undefined values to NULL for INSERT
statements, which could cause issues when inserting into NOT NULL columns.
This change makes INSERT behave consistently with UPDATE, which already skips
undefined values.
Now when using `sql({ foo: undefined, id: 1 })` in an INSERT:
- The `foo` column is omitted entirely from the query
- Only columns with defined values are included
- If all columns have undefined values, a descriptive error is thrown
This aligns with the expected JavaScript behavior where undefined typically
means "not present" rather than "explicitly null".
Fixes #22156 (comment from EvHaus about INSERT statements)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>