feat(export): add portable standard SQL inserts

Closes #9869
This commit is contained in:
t8y2 committed 2026-09-27 15:56:52 +00:00
1 parent ba3872abef
commit 1d07cb05e0
22 files changed
+384 -83

No files matched your search

@@ -4,6 +4,7 @@ import { buildTableSelectSql } from "@/lib/table/tableSelectSql.ts";
import { uuid } from "@/lib/common/utils.ts";
import { SINGLE_DATABASE_TYPES } from "@/lib/database/databaseCapabilitySets";
import { isXuguSyntheticScope } from "@/lib/sidebar/xuguPublicSynonyms";
import type { SqlInsertDialect } from "@/lib/export/sqlInsertMode";
export const DATABASE_EXPORT_ROW_LIMIT = 10_000;
export const DATABASE_EXPORT_PAGE_SIZE = 500;
@@ -31,6 +32,7 @@ export interface BuildDatabaseSqlExportOptions {
tables: ExportedTableSql[];
rowLimitPerTable?: number;
insertBatchSize?: number;
insertDialect?: SqlInsertDialect;
connectionId?: string;
database?: string;
schema?: string;
@@ -52,6 +54,10 @@ export interface BuildExportInsertStatementsOptions {
batchSize?: number;
}
export interface BuildExportSqlInsertOptions extends BuildExportInsertStatementsOptions {
insertDialect?: SqlInsertDialect;
}
export interface BuildExportPageSqlOptions {
databaseType?: DatabaseType;
driverProfile?: string;
+2 -1
View File
@@ -1,7 +1,7 @@
import type { DatabaseType, QueryResult } from "@/types/database";
import * as api from "@/lib/backend/api";
import { escapeCsvField, type CsvQuoteMode } from "@/lib/export/csvQuoteMode";
import type { SqlInsertMode } from "@/lib/export/sqlInsertMode";
import type { SqlInsertDialect, SqlInsertMode } from "@/lib/export/sqlInsertMode";
export type ExportCellValue = string | number | boolean | null;
@@ -45,6 +45,7 @@ export interface FormatSqlInsertOptions {
spatialValues?: QueryResult["spatial_values"];
rows: ExportCellValue[][];
insertMode?: SqlInsertMode;
insertDialect?: SqlInsertDialect;
excludeColumns?: string[];
}
@@ -3,6 +3,7 @@ import SqlInsertModeDialog from "@/components/export/SqlInsertModeDialog.vue";
import i18n from "@/i18n";
export type SqlInsertMode = "batch" | "single";
export type SqlInsertDialect = "source" | "standard";
export interface SqlExportOptions {
insertMode: SqlInsertMode;
@@ -10,6 +11,7 @@ export interface SqlExportOptions {
}
export const DEFAULT_SQL_INSERT_MODE: SqlInsertMode = "batch";
export const DEFAULT_SQL_INSERT_DIALECT: SqlInsertDialect = "source";
export function showSqlInsertModeDialog(options: { allowSplit?: boolean } = {}): Promise<SqlExportOptions | null> {
if (typeof document === "undefined") return Promise.resolve({ insertMode: DEFAULT_SQL_INSERT_MODE });