Skip to content

transform: coerce empty strings to NULL when converting TEXT columns to numeric types - #805

Merged
simonw merged 3 commits into
simonw:mainfrom
ikatyal2110:fix/transform-empty-string-to-null
Aug 13, 2026
Merged

simonw merged 3 commits into
simonw:mainfrom
ikatyal2110:fix/transform-empty-string-to-null

Conversation

@ikatyal2110

@ikatyal2110 ikatyal2110 commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

When .transform() copies data from a TEXT column into a newly-typed INTEGER, FLOAT, or REAL column, empty string values ("") are now converted to NULL via NULLIF(col, '') in the INSERT … SELECT statement, instead of being stored as empty strings in the numeric column. Non-empty strings that represent valid numbers continue to be coerced by SQLite as before, and NULL values are preserved unchanged. Fixes:


Generated by Claude Code


📚 Documentation preview 📚: https://sqlite-utils--805.org.readthedocs.build/en/805/

…to numeric types

When a TEXT column is transformed to INTEGER, FLOAT, or REAL and a row
contains an empty string, the empty string is now converted to NULL during
the INSERT...SELECT copy, matching the expected behavior described in simonw#488.

Fixes simonw#488
@simonw
simonw force-pushed the fix/transform-empty-string-to-null branch from 2b254d7 to 30b4a8c Compare August 13, 2026 18:25
@simonw
simonw merged commit e4935e0 into simonw:main Aug 13, 2026
53 checks passed
@simonw simonw added the enhancement New feature or request label Aug 13, 2026
simonw added a commit that referenced this pull request Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants