25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
feat(grid): support multi-row Copy as INSERT
t8y2004b5645c5c0
diff --git a/src/components/grid/DataGrid.vue b/src/components/grid/DataGrid.vueindex 8de26282f8..6999d57fff 100644--- a/src/components/grid/DataGrid.vue+++ b/src/components/grid/DataGrid.vue@@ -1402,6 +1402,7 @@ const {databaseType: computed(() => props.databaseType),hasCellSelection,selectedCells,+ selectedRange,contextCell: exportContextCell,getRowItem: (rowId: number) => visibleDisplayItems.value.find((item) => item.id === rowId),quoteIdent,diff --git a/src/composables/useDataGridExport.ts b/src/composables/useDataGridExport.tsindex 0c9a9f002d..ab9624207d 100644--- a/src/composables/useDataGridExport.ts+++ b/src/composables/useDataGridExport.ts@@ -7,6 +7,7 @@ import {formatSelectionAsJson,formatSelectionAsSqlInList,formatSelectionAsTsv,+ type CellSelectionRange,type SelectionData,} from "@/lib/gridSelection";import { useToast } from "@/composables/useToast";@@ -31,6 +32,7 @@ export interface UseDataGridExportOptions {databaseType: ComputedRef<string | undefined>;hasCellSelection: ComputedRef<boolean>;selectedCells: ComputedRef<SelectionData>;+ selectedRange: ComputedRef<CellSelectionRange | null>;contextCell:| Ref<{ rowId: number; rowIndex: number; col: number } | null>| ComputedRef<{ rowId: number; rowIndex: number; col: number } | null>;@@ -50,6 +52,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {tableMeta,hasCellSelection,selectedCells,+ selectedRange,contextCell,getRowItem,quoteIdent,@@ -102,14 +105,24 @@ export function useDataGridExport(options: UseDataGridExportOptions) {}function copyRowAsInsert() {+ const table = tableMeta.value+ ? (tableMeta.value.schema ? `${quoteIdent(tableMeta.value.schema)}.` : "") + quoteIdent(tableMeta.value.tableName)+ : "table_name";+ const cols = columns.value.map((c) => quoteIdent(c)).join(", ");+ const range = selectedRange.value;+ if (range && range.startRow !== range.endRow) {+ const items = displayItems.value.slice(range.startRow, range.endRow + 1);+ const statements = items.map((item) => {+ const vals = item.data.map((v) => escapeVal(v)).join(", ");+ return `INSERT INTO ${table} (${cols}) VALUES (${vals});`;+ });+ copyText(statements.join("\n"));+ return;+ }if (!contextCell.value) return;const item = getRowItem(contextCell.value.rowId);if (!item) return;- const cols = columns.value.map((c) => quoteIdent(c)).join(", ");const vals = item.data.map((v) => escapeVal(v)).join(", ");- const table = tableMeta.value- ? (tableMeta.value.schema ? `${quoteIdent(tableMeta.value.schema)}.` : "") + quoteIdent(tableMeta.value.tableName)- : "table_name";copyText(`INSERT INTO ${table} (${cols}) VALUES (${vals});`);}