feat(extractor): configure INSERT quoting and portable temporal output

Closes #10559
This commit is contained in:
t8y2 committed 2026-10-03 04:17:17 +00:00
1 parent a95762a536
commit d4b4cf8279
13 files changed
+725 -20

No files matched your search

@@ -2,6 +2,16 @@ import { describe, expect, it } from "vitest";
import { DEFAULT_DATA_GRID_EXTRACTOR_OPTIONS, normalizeDataGridCopyPreference, normalizeDataGridExtractorOptions, resolveDataGridCopyPreference, validateDataGridExtractorOptions } from "@/lib/dataGrid/dataGridCopyExtractor";
describe("data-grid extractor options", () => {
it("preserves native SQL defaults and normalizes portable INSERT options", () => {
for (const legacy of [undefined, {}, { sql: {} }, { sql: { insertMode: "row-by-row" } }]) {
expect(normalizeDataGridExtractorOptions(legacy).sql).toMatchObject({ quoteIdentifiers: true, temporalFormat: "native" });
}
const configured = normalizeDataGridExtractorOptions({ sql: { quoteIdentifiers: false, temporalFormat: "string" } });
expect(configured.sql).toMatchObject({ quoteIdentifiers: false, temporalFormat: "string" });
expect(normalizeDataGridExtractorOptions(JSON.parse(JSON.stringify(configured)))).toEqual(configured);
expect(normalizeDataGridExtractorOptions({ sql: { quoteIdentifiers: "false", temporalFormat: "custom" } }).sql).toMatchObject({ quoteIdentifiers: true, temporalFormat: "native" });
});
it("keeps database qualification for legacy options and persists explicit opt-out", () => {
expect(normalizeDataGridExtractorOptions({ sql: {} }).sql.includeDatabaseName).toBe(true);
const configured = normalizeDataGridExtractorOptions({ sql: { includeDatabaseName: false } });
@@ -89,6 +89,8 @@ export interface DataGridExtractorOptions {
insertMode: DataGridCopyInsertMode;
excludePrimaryKeysFromInsert: boolean;
includeDatabaseName: boolean;
quoteIdentifiers: boolean;
temporalFormat: "native" | "string";
};
json: {
pretty: boolean;
@@ -150,6 +152,8 @@ export const DEFAULT_DATA_GRID_EXTRACTOR_OPTIONS: DataGridExtractorOptions = {
insertMode: "merged",
excludePrimaryKeysFromInsert: false,
includeDatabaseName: true,
quoteIdentifiers: true,
temporalFormat: "native",
},
json: { pretty: true, camelCaseFieldNames: false },
};
@@ -181,6 +185,8 @@ export function normalizeDataGridExtractorOptions(value: unknown): DataGridExtra
insertMode: sql.insertMode === "row-by-row" ? "row-by-row" : "merged",
excludePrimaryKeysFromInsert: sql.excludePrimaryKeysFromInsert === true,
includeDatabaseName: sql.includeDatabaseName !== false,
quoteIdentifiers: sql.quoteIdentifiers !== false,
temporalFormat: sql.temporalFormat === "string" ? "string" : "native",
},
json: {
pretty: json.pretty !== false,