1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-06-05 21:59:22 +02:00

feat: export table content as SQL INSERT

This commit is contained in:
2022-07-25 12:19:58 +02:00
parent d4b6d2e9d1
commit f3b5de38c4
12 changed files with 218 additions and 139 deletions

View File

@ -121,7 +121,7 @@ import { uidGen } from 'common/libs/uidGen';
import { useSettingsStore } from '@/stores/settings';
import { useWorkspacesStore } from '@/stores/workspaces';
import { useConsoleStore } from '@/stores/console';
import { arrayToFile } from '../libs/arrayToFile';
import { exportRows } from '../libs/exportRows';
import { TEXT, LONG_TEXT, BLOB } from 'common/fieldTypes';
import BaseVirtualScroll from '@/components/BaseVirtualScroll.vue';
import WorkspaceTabQueryTableRow from '@/components/WorkspaceTabQueryTableRow.vue';
@ -177,6 +177,7 @@ const selectedField = ref(null);
const isEditingRow = ref(false);
const workspaceSchema = computed(() => getWorkspace(props.connUid).breadcrumbs.schema);
const workspaceClient = computed(() => getWorkspace(props.connUid).client);
const primaryField = computed(() => {
const primaryFields = fields.value.filter(field => field.key === 'pri');
@ -534,7 +535,7 @@ const selectResultset = (index: number) => {
resultsetIndex.value = index;
};
const downloadTable = (format: 'csv' | 'json', filename: string) => {
const downloadTable = (format: 'csv' | 'json' | 'sql', table: string) => {
if (!sortedResults.value) return;
const rows = JSON.parse(JSON.stringify(sortedResults.value)).map((row: any) => {
@ -542,10 +543,14 @@ const downloadTable = (format: 'csv' | 'json', filename: string) => {
return row;
});
arrayToFile({
exportRows({
type: format,
content: rows,
filename
fields: fieldsObj.value as {
[key: string]: {type: string; datePrecision: number};
},
client: workspaceClient.value,
table
});
};