fix(export): mark NULL as \N in CSV and TSV exports

This commit is contained in:
zipg authored and GitHub committed 2026-09-28 22:35:43 +08:00
1 parent 02f27dc294
commit 1aaa5ca717
49 files changed
+1056 -130

No files matched your search

@@ -236,6 +236,11 @@ describe("editorSettingsDraftFromSettings", () => {
expect(draft.completionTriggerMode).toBe("positional");
});
it("maps csvNullMode and normalizes an unknown value back to the marker", () => {
expect(editorSettingsDraftFromSettings(makeSettings({ csvNullMode: "empty" })).csvNullMode).toBe("empty");
expect(editorSettingsDraftFromSettings(makeSettings({ csvNullMode: "bogus" as unknown } as Partial<EditorSettings>)).csvNullMode).toBe("marker");
});
it("maps and normalizes tableCompletionSchemaQualification", () => {
expect(editorSettingsDraftFromSettings(makeSettings({ tableCompletionSchemaQualification: "always" })).tableCompletionSchemaQualification).toBe("always");
expect(editorSettingsDraftFromSettings(makeSettings({ tableCompletionSchemaQualification: "invalid" } as any)).tableCompletionSchemaQualification).toBe("collision");
@@ -413,4 +413,9 @@ describe("settingsTransfer", () => {
expect(transferCategoryForKey("csvQuoteMode")).toBe("data");
expect(collectTransferCategories(["csvQuoteMode", "pageSize"])).toEqual(["data"]);
});
it("maps csvNullMode into the data category", () => {
expect(transferCategoryForKey("csvNullMode")).toBe("data");
expect(collectTransferCategories(["csvNullMode", "csvQuoteMode"])).toEqual(["data"]);
});
});
@@ -7,6 +7,7 @@ import { normalizeCompletionTriggerMode } from "@/lib/sql/sqlCompletionTriggerPo
import { normalizeSqlTableCompletionSchemaQualification } from "@/lib/sql/sqlCompletionSchemaQualification";
import { normalizeTableHoverLookupMode } from "@/lib/editor/hoverTableLookup";
import { normalizeRedisKeyTemplates } from "@/lib/redis/redisKeyTemplates";
import { normalizeCsvNullMode } from "@/lib/export/csvNullMode";
export const EDITOR_SETTINGS_DRAFT_KEYS = [
"fontFamily",
@@ -120,6 +121,7 @@ export const EDITOR_SETTINGS_DRAFT_KEYS = [
"redisDatabaseDisplayLimit",
"exportBatchSize",
"csvQuoteMode",
"csvNullMode",
"exportRowLimitEnabled",
"exportRowLimit",
"queryExportKeysetOptimizationEnabled",
@@ -164,6 +166,7 @@ function normalizedDraftValue(key: EditorSettingsDraftKey, value: unknown): unkn
if (key === "tableCompletionSchemaQualification") return normalizeSqlTableCompletionSchemaQualification(value);
if (key === "tableHoverLookupMode") return normalizeTableHoverLookupMode(value);
if (key === "redisKeyTemplates") return normalizeRedisKeyTemplates(value);
if (key === "csvNullMode") return normalizeCsvNullMode(value);
if (key === "backgroundImage") return normalizeBackgroundImageSettings(value);
return value;
}
@@ -178,6 +178,7 @@ const SETTINGS_TRANSFER_CATEGORY_KEYS: Record<SettingsTransferCategoryId, readon
"redisDatabaseDisplayLimit",
"exportBatchSize",
"csvQuoteMode",
"csvNullMode",
"exportRowLimitEnabled",
"exportRowLimit",
"queryExportKeysetOptimizationEnabled",