Skip to content

Fix transform to convert empty strings to NULL when changing to integer or float type#785

Open
ikatyal2110 wants to merge 1 commit into
simonw:mainfrom
ikatyal2110:fix-transform-empty-string-to-null
Open

Fix transform to convert empty strings to NULL when changing to integer or float type#785
ikatyal2110 wants to merge 1 commit into
simonw:mainfrom
ikatyal2110:fix-transform-empty-string-to-null

Conversation

@ikatyal2110

@ikatyal2110 ikatyal2110 commented Jul 8, 2026

Copy link
Copy Markdown

When you run .transform(types={"age": int}) on a table that has empty strings in a TEXT column, the empty strings currently survive as "" in the new INTEGER/FLOAT column instead of becoming NULL.

The fix wraps the SELECT expression with NULLIF(col, '') for any column explicitly being converted to a numeric type, so empty strings become NULL during the data copy step.

Text columns and columns not listed in types are not affected.

Fixes #488


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

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.

sqlite-utils transform should set empty strings to null when converting text columns to integer/float

2 participants