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
@@ -209,6 +209,9 @@ function save() {
|
||||
<label v-if="draftExtractor === 'sql-inserts'" class="flex items-center gap-2 text-sm"
|
||||
><input type="checkbox" :checked="draftOptions.sql.excludePrimaryKeysFromInsert" @change="updateSql('excludePrimaryKeysFromInsert', ($event.target as HTMLInputElement).checked)" />{{ t("grid.copyExtractorExcludePrimaryKeys") }}</label
|
||||
>
|
||||
<label v-if="draftExtractor === 'sql-inserts'" class="flex items-center gap-2 text-sm"
|
||||
><input type="checkbox" :checked="draftOptions.sql.includeDatabaseName" @change="updateSql('includeDatabaseName', ($event.target as HTMLInputElement).checked)" />{{ t("grid.copyExtractorIncludeDatabaseName") }}</label
|
||||
>
|
||||
<div v-if="draftExtractor === 'sql-inserts'" class="space-y-1.5">
|
||||
<Label>{{ t("grid.copyExtractorInsertMode") }}</Label>
|
||||
<Select :model-value="draftOptions.sql.insertMode" @update:model-value="updateSql('insertMode', $event as DataGridExtractorOptions['sql']['insertMode'])">
|
||||
|
||||
@@ -1754,6 +1754,7 @@ export default withEnglishFallback({
|
||||
copyExtractorSkipComputed: "Hesablanan sütunları ötür",
|
||||
copyExtractorSkipGenerated: "Avtomatik yaradılan sütunları ötür",
|
||||
copyExtractorExcludePrimaryKeys: "Əsas açarları istisna et",
|
||||
copyExtractorIncludeDatabaseName: "Verilənlər bazasının adını daxil et",
|
||||
copyExtractorInsertMode: "INSERT əmrləri",
|
||||
copyExtractorInsertMerged: "Sətirləri birləşdir",
|
||||
copyExtractorInsertRowByRow: "Hər sətir üçün bir əmr",
|
||||
|
||||
@@ -1903,6 +1903,7 @@ export default {
|
||||
copyExtractorSkipComputed: "Skip computed columns",
|
||||
copyExtractorSkipGenerated: "Skip generated columns",
|
||||
copyExtractorExcludePrimaryKeys: "Exclude primary keys",
|
||||
copyExtractorIncludeDatabaseName: "Include database name",
|
||||
copyExtractorInsertMode: "INSERT statements",
|
||||
copyExtractorInsertMerged: "Merge rows",
|
||||
copyExtractorInsertRowByRow: "One statement per row",
|
||||
|
||||
@@ -2348,6 +2348,7 @@ export default withEnglishFallback({
|
||||
copyExtractorSkipComputed: "Saltar columnas calculadas",
|
||||
copyExtractorSkipGenerated: "Saltar columnas generadas",
|
||||
copyExtractorExcludePrimaryKeys: "Excluir claves primarias",
|
||||
copyExtractorIncludeDatabaseName: "Incluir el nombre de la base de datos",
|
||||
copyExtractorInsertMode: "Modo de sentencia INSERT",
|
||||
copyExtractorInsertMerged: "Combinar varias filas",
|
||||
copyExtractorInsertRowByRow: "Una sentencia por fila",
|
||||
|
||||
@@ -2346,6 +2346,7 @@ export default withEnglishFallback({
|
||||
copyExtractorSkipComputed: "Salta colonne calcolate",
|
||||
copyExtractorSkipGenerated: "Salta colonne generate",
|
||||
copyExtractorExcludePrimaryKeys: "Escludi chiavi primarie",
|
||||
copyExtractorIncludeDatabaseName: "Includi il nome del database",
|
||||
copyExtractorInsertMode: "Modalità istruzione INSERT",
|
||||
copyExtractorInsertMerged: "Unisci più righe",
|
||||
copyExtractorInsertRowByRow: "Una istruzione per riga",
|
||||
|
||||
@@ -2368,6 +2368,7 @@ export default withEnglishFallback({
|
||||
copyExtractorSkipComputed: "計算列をスキップ",
|
||||
copyExtractorSkipGenerated: "生成列をスキップ",
|
||||
copyExtractorExcludePrimaryKeys: "主キーを除外",
|
||||
copyExtractorIncludeDatabaseName: "データベース名を含める",
|
||||
copyExtractorInsertMode: "INSERT文モード",
|
||||
copyExtractorInsertMerged: "複数行をマージ",
|
||||
copyExtractorInsertRowByRow: "1行ごとに1文",
|
||||
|
||||
@@ -1773,6 +1773,7 @@ export default withEnglishFallback({
|
||||
copyExtractorSkipComputed: "계산된 컬럼 건너뛰기",
|
||||
copyExtractorSkipGenerated: "생성된 컬럼 건너뛰기",
|
||||
copyExtractorExcludePrimaryKeys: "기본 키 제외",
|
||||
copyExtractorIncludeDatabaseName: "데이터베이스 이름 포함",
|
||||
copyExtractorInsertMode: "INSERT 구문",
|
||||
copyExtractorInsertMerged: "행 병합",
|
||||
copyExtractorInsertRowByRow: "행별 한 구문",
|
||||
|
||||
@@ -2348,6 +2348,7 @@ export default withEnglishFallback({
|
||||
copyExtractorSkipComputed: "Pular colunas computadas",
|
||||
copyExtractorSkipGenerated: "Pular colunas geradas",
|
||||
copyExtractorExcludePrimaryKeys: "Excluir chaves primárias",
|
||||
copyExtractorIncludeDatabaseName: "Incluir nome do banco de dados",
|
||||
copyExtractorInsertMode: "Modo de instrução INSERT",
|
||||
copyExtractorInsertMerged: "Mesclar várias linhas",
|
||||
copyExtractorInsertRowByRow: "Uma instrução por linha",
|
||||
|
||||
@@ -1755,6 +1755,7 @@ export default withEnglishFallback({
|
||||
copyExtractorSkipComputed: "Hesaplanan sütunları atla",
|
||||
copyExtractorSkipGenerated: "Üretilen sütunları atla",
|
||||
copyExtractorExcludePrimaryKeys: "Birincil anahtarları hariç tut",
|
||||
copyExtractorIncludeDatabaseName: "Veritabanı adını dahil et",
|
||||
copyExtractorInsertMode: "INSERT ifadeleri",
|
||||
copyExtractorInsertMerged: "Satırları birleştir",
|
||||
copyExtractorInsertRowByRow: "Her satır için bir ifade",
|
||||
|
||||
@@ -1817,6 +1817,7 @@ export default withEnglishFallback({
|
||||
copyExtractorSkipComputed: "跳过计算列",
|
||||
copyExtractorSkipGenerated: "跳过生成列",
|
||||
copyExtractorExcludePrimaryKeys: "排除主键",
|
||||
copyExtractorIncludeDatabaseName: "包含数据库名称",
|
||||
copyExtractorInsertMode: "INSERT 语句模式",
|
||||
copyExtractorInsertMerged: "合并多行",
|
||||
copyExtractorInsertRowByRow: "每行一条语句",
|
||||
|
||||
@@ -2354,6 +2354,7 @@ export default withEnglishFallback({
|
||||
copyExtractorSkipComputed: "跳過計算列",
|
||||
copyExtractorSkipGenerated: "跳過生成列",
|
||||
copyExtractorExcludePrimaryKeys: "排除主鍵",
|
||||
copyExtractorIncludeDatabaseName: "包含資料庫名稱",
|
||||
copyExtractorInsertMode: "INSERT 語句模式",
|
||||
copyExtractorInsertMerged: "合併多行",
|
||||
copyExtractorInsertRowByRow: "每行一條語句",
|
||||
|
||||
@@ -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