fix(export): stream JSON query exports and allow web TXT
This commit is contained in:
8 files changed
+140
-11
No files matched your search
@@ -139,4 +139,12 @@ describe("query result SQL export progress", () => {
|
||||
expect(cancelHandler.value).toBeNull();
|
||||
expect(api.startQueryResultExport).toHaveBeenCalledWith(expect.objectContaining({ format: "sql", exportTableName: "users", exportColumnTypes: ["int4", "text"] }), expect.any(Function));
|
||||
});
|
||||
|
||||
it("routes incomplete query-result JSON exports through the streaming backend", async () => {
|
||||
const state = useDataGridExport(createOptions());
|
||||
|
||||
await state.exportJson();
|
||||
|
||||
expect(api.startQueryResultExport).toHaveBeenCalledWith(expect.objectContaining({ format: "json", sql: "SELECT id, name FROM users" }), expect.any(Function));
|
||||
});
|
||||
});
|
||||
@@ -116,7 +116,7 @@ export interface UseDataGridExportOptions {
|
||||
queryResultExportRequest?: (options: {
|
||||
exportId: string;
|
||||
filePath: string;
|
||||
format: "csv" | "xlsx" | "txt" | "sql";
|
||||
format: "csv" | "xlsx" | "json" | "txt" | "sql";
|
||||
includeSqlSheet?: boolean;
|
||||
exportTableName?: string;
|
||||
exportColumnTypes?: Array<string | null | undefined>;
|
||||
@@ -878,6 +878,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
|
||||
await runExclusiveExport(async () => {
|
||||
try {
|
||||
if (await exportFullTableDataViaBackend("json", rowIds)) return;
|
||||
if (await exportQueryResultViaBackend("json", rowIds)) return;
|
||||
|
||||
let outputPath = exportFileName("export", "json");
|
||||
if (isTauriRuntime()) {
|
||||
@@ -1267,7 +1268,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
|
||||
return true;
|
||||
}
|
||||
|
||||
async function exportQueryResultViaBackend(format: "csv" | "xlsx" | "txt" | "sql", rowIds?: number[], includeSqlSheet = false, headerMode: XlsxHeaderMode = "name", autoFilter = true, insertMode?: SqlInsertMode): Promise<boolean> {
|
||||
async function exportQueryResultViaBackend(format: "csv" | "xlsx" | "json" | "txt" | "sql", rowIds?: number[], includeSqlSheet = false, headerMode: XlsxHeaderMode = "name", autoFilter = true, insertMode?: SqlInsertMode): Promise<boolean> {
|
||||
if (rowIds !== undefined || context.value !== "results" || !queryResultExportRequest) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user