feat(export): add SQL INSERT batch or single-row mode
This commit is contained in:
1 parent
5d65be03a3
commit
ab35a5b1da
29 files changed
+563
-23
No files matched your search
@@ -77,6 +77,31 @@ describe("queryStore query result export", () => {
|
||||
expect(mocks.connectionIdentifierQuote).toHaveBeenCalledWith("kingbase-1");
|
||||
});
|
||||
|
||||
it("passes the selected SQL INSERT mode to the backend request", async () => {
|
||||
const { useQueryStore } = await import("@/stores/queryStore");
|
||||
const store = useQueryStore();
|
||||
const tabId = store.createTab("kingbase-1", "app", "Query");
|
||||
const tab = store.tabs.find((item) => item.id === tabId)!;
|
||||
tab.sql = "SELECT id, name FROM users";
|
||||
tab.lastExecutedSql = tab.sql;
|
||||
tab.result = {
|
||||
columns: ["id", "name"],
|
||||
rows: [[1, "Ada"]],
|
||||
affected_rows: 0,
|
||||
execution_time_ms: 1,
|
||||
};
|
||||
|
||||
const request = await store.buildQueryResultExportRequest(tabId, {
|
||||
exportId: "export-single",
|
||||
filePath: "users.sql",
|
||||
format: "sql",
|
||||
exportTableName: "users",
|
||||
insertMode: "single",
|
||||
});
|
||||
|
||||
expect(request?.insertMode).toBe("single");
|
||||
});
|
||||
|
||||
it("uses the Agent cursor for SQL Server legacy result export", async () => {
|
||||
mocks.getConfig.mockReturnValue({
|
||||
id: "sqlserver-2000",
|
||||
|
||||
@@ -41,6 +41,7 @@ import { TABLE_DATA_EXPORT_PAGE_SIZE } from "@/lib/table/tableDataExport";
|
||||
import { tableMetaForDataTab } from "@/lib/table/tableDataTabMeta";
|
||||
import { isDataTabMetadataLifecycleStale } from "@/lib/sidebar/dataTabOpenPolicy";
|
||||
import { dataTabExecutionDatabase } from "@/lib/table/dataTabExecutionDatabase";
|
||||
import type { SqlInsertMode } from "@/lib/export/sqlInsertMode";
|
||||
import { tableOpenPageLimit } from "@/lib/table/tableOpenPageLimit";
|
||||
import { getCachedTableMetadata, loadTableColumns, loadTableIndexes, loadTableMetadata, tableMetadataToDataTabMeta, updateCachedTableMetadataType, type TableMetadataRequest } from "@/lib/metadata/tableMetadataCache";
|
||||
import { MetadataTaskLimiter } from "@/lib/metadata/metadataTaskLimiter";
|
||||
@@ -149,6 +150,7 @@ interface BuildQueryResultExportRequestOptions {
|
||||
includeSqlSheet?: boolean;
|
||||
exportTableName?: string;
|
||||
exportColumnTypes?: Array<string | null | undefined>;
|
||||
insertMode?: SqlInsertMode;
|
||||
}
|
||||
|
||||
interface OpenSavedSqlOptions {
|
||||
@@ -7558,6 +7560,7 @@ export const useQueryStore = defineStore("query", () => {
|
||||
useAgentCursor,
|
||||
filePath: options.filePath,
|
||||
format: options.format,
|
||||
...(options.format === "sql" && options.insertMode ? { insertMode: options.insertMode } : {}),
|
||||
includeSqlSheet: options.format === "xlsx" && options.includeSqlSheet === true,
|
||||
pageSize: settings.exportBatchSize,
|
||||
rowLimit,
|
||||
|
||||
Reference in new issue
Block a user