Files
bun.sh/test/js/sql/sqlite-sql.test.ts
Claude Bot dcdf2537e8 fix(sql): filter out undefined values in INSERT helper instead of treating as NULL
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>
2026-01-03 20:11:47 +00:00

164 KiB