feat(data-grid): optional database/schema prefix in copied INSERT SQL
This commit is contained in:
19 files changed
+220
-1
No files matched your search
@@ -3,6 +3,13 @@ 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("keeps database qualification for legacy options and persists explicit opt-out", () => {
|
||||
expect(normalizeDataGridExtractorOptions({ sql: {} }).sql.includeDatabaseName).toBe(true);
|
||||
const configured = normalizeDataGridExtractorOptions({ sql: { includeDatabaseName: false } });
|
||||
expect(normalizeDataGridExtractorOptions(JSON.parse(JSON.stringify(configured))).sql.includeDatabaseName).toBe(false);
|
||||
expect(normalizeDataGridExtractorOptions({ sql: { includeDatabaseName: "false" } }).sql.includeDatabaseName).toBe(true);
|
||||
});
|
||||
|
||||
it("defaults DSV NULL output to an empty spreadsheet field", () => {
|
||||
expect(DEFAULT_DATA_GRID_EXTRACTOR_OPTIONS.dsv.nullText).toBe("");
|
||||
expect(normalizeDataGridExtractorOptions({}).dsv.nullText).toBe("");
|
||||
|
||||
@@ -88,6 +88,7 @@ export interface DataGridExtractorOptions {
|
||||
skipGeneratedColumns: boolean;
|
||||
insertMode: DataGridCopyInsertMode;
|
||||
excludePrimaryKeysFromInsert: boolean;
|
||||
includeDatabaseName: boolean;
|
||||
};
|
||||
json: {
|
||||
pretty: boolean;
|
||||
@@ -148,6 +149,7 @@ export const DEFAULT_DATA_GRID_EXTRACTOR_OPTIONS: DataGridExtractorOptions = {
|
||||
skipGeneratedColumns: true,
|
||||
insertMode: "merged",
|
||||
excludePrimaryKeysFromInsert: false,
|
||||
includeDatabaseName: true,
|
||||
},
|
||||
json: { pretty: true, camelCaseFieldNames: false },
|
||||
};
|
||||
@@ -178,6 +180,7 @@ export function normalizeDataGridExtractorOptions(value: unknown): DataGridExtra
|
||||
skipGeneratedColumns: sql.skipGeneratedColumns !== false,
|
||||
insertMode: sql.insertMode === "row-by-row" ? "row-by-row" : "merged",
|
||||
excludePrimaryKeysFromInsert: sql.excludePrimaryKeysFromInsert === true,
|
||||
includeDatabaseName: sql.includeDatabaseName !== false,
|
||||
},
|
||||
json: {
|
||||
pretty: json.pretty !== false,
|
||||
|
||||
@@ -56,6 +56,7 @@ export interface DataGridCopyInsertStatementOptions {
|
||||
rows: GridCellValue[][];
|
||||
excludePrimaryKeys?: boolean;
|
||||
includeComputedColumns?: boolean;
|
||||
includeDatabaseName?: boolean;
|
||||
insertMode?: DataGridCopyInsertMode;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user