You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[P1][bug] CSV import turns every empty cell into NULL, which is a choice the file cannot express #578
generateBatchInsert writes an empty cell as SQL NULL:
if(value===""){return"NULL";}
CSV distinguishes ,, from ,"", — an absent value from an empty string — but csv-parser.ts returns string[][], so both arrive here as "" and the distinction is already gone by the time this decision is made.
Why it matters
Two different failures, depending on the column:
NOT NULL column — the import fails on a row the user considers valid, with an error naming NULL when their file contained an empty string.
Nullable column — the import succeeds and stores NULL where the file said "". Silent, and only visible later to whatever reads the column and distinguishes the two.
Neither is unreasonable as a default; both are unreasonable as a decision made invisibly.
Suggested fix
Two parts, and the first is required for the second to be possible:
Keep the distinction in the parser.parseCSVLine knows whether a field was quoted; that information is discarded when it returns a plain string. Returning something that preserves "was quoted" (or a null for a bare empty field) puts the choice back in reach.
Let the user pick, with a sensible default — the import dialog already has a CSV options block. The conventional default is bare empty → NULL, quoted empty → "", which is what mysqlimport and most ETL tools do.
Worth doing together with #366, which also wants changes in the parser.
Where it stands
Documented at the call site rather than left implicit, as part of the #364 work — the comment names this issue so the next reader knows it is a choice and not an oversight.
Already fixed — recording the check rather than the change.
parseCSVLine keeps whether each field was quoted (bareEmpty), parseCSV carries it through, and generateBatchInsert uses it:
,, → NULL
,"", → ''
a short row's missing cells → NULL, since an absent cell is absent
That is mysqlimport's convention and the default this issue proposed. Tests in csv-parser.test.ts pin the flags, and sql-import.test.ts pins what each becomes in the INSERT.
No option is exposed, and deliberately: this issue's own framing was "a choice the file cannot express", and the file can now express it. An override would only matter for a file that quotes every field including the empty ones, where the writer has said "empty string" and meant it — which is what we would then be overriding.
Activity
fix(import): one escape table, and say what a dump will drop (#579)
fix(import): refuse files too large to open, and let the file say emp…
EVWorth commentedon Sep 12, 2026
Already fixed — recording the check rather than the change.
parseCSVLinekeeps whether each field was quoted (bareEmpty),parseCSVcarries it through, andgenerateBatchInsertuses it:,,→NULL,"",→''NULL, since an absent cell is absentThat is
mysqlimport's convention and the default this issue proposed. Tests incsv-parser.test.tspin the flags, andsql-import.test.tspins what each becomes in the INSERT.No option is exposed, and deliberately: this issue's own framing was "a choice the file cannot express", and the file can now express it. An override would only matter for a file that quotes every field including the empty ones, where the writer has said "empty string" and meant it — which is what we would then be overriding.
test(import): a CSV all the way to the statements that load it (#655)