fix(csv-to-pg): add preserveEmptyStrings option, default true#1089
Merged
pyramation merged 3 commits intomainfrom May 9, 2026
Merged
fix(csv-to-pg): add preserveEmptyStrings option, default true#1089pyramation merged 3 commits intomainfrom
pyramation merged 3 commits intomainfrom
Conversation
…erting to NULL The text type coercion was calling cleanseEmptyStrings() which treated empty strings as NULL tokens. This is incorrect for database export/re-import workflows where PostgreSQL distinguishes between '' and NULL. This caused the webauthn_settings migration to fail: the table has rp_id/rp_name as NOT NULL DEFAULT '', but the export converted '' to NULL, producing an INSERT that violates the NOT NULL constraint. The fix: for text fields, only treat actual null/undefined as NULL. Empty strings are preserved as valid text values.
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Instead of unconditionally changing the text coercion behavior, add a preserveEmptyStrings option that controls whether empty strings are treated as NULL tokens (the default CSV convention) or preserved as valid text values. - Default behavior unchanged: empty strings → NULL (CSV convention) - preserveEmptyStrings: true → empty strings preserved as '' - export-meta.ts sets preserveEmptyStrings: true since database data distinguishes between '' and NULL This fixes the webauthn_settings migration failure where rp_id/rp_name default to '' but the export converted them to NULL.
Empty strings are valid text values in PostgreSQL and should be preserved by default. The setting can be set to false to opt into the CSV convention of treating empty strings as NULL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
texttype coercion incsv-to-pgcalledcleanseEmptyStrings()which treats''as a NULL token. This is wrong for PostgreSQL where''andNULLare distinct values.Root cause: When the
webauthn_settingstrigger insertsrp_id = ''(the NOT NULL default), the export converts''→NULL. The subsequent migration fails with:Fix: Add a
preserveEmptyStringsoption to the Parser:true): Empty strings preserved as''— correct for PostgreSQLfalse: Empty strings → NULL (CSV convention, opt-in)This unblocks constructive-db PR #1078.
Review & Testing Checklist for Human
Notes
Link to Devin session: https://app.devin.ai/sessions/18d6c72085dc4b06b1428e2baddbf430
Requested by: @pyramation