fix(grid): refresh copied insert after row edits

This commit is contained in:
t8y2 committed 2026-07-01 02:10:47 +08:00
1 parent e83f41c63c
commit c2bae3b957
2 files changed
+63 -2

No files matched your search

@@ -178,7 +178,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
}
function updateCopyKey(): string {
const rows = updateEligibleRows().map((item) => item.id);
const rows = copyStatementRowsKey(updateEligibleRows());
return JSON.stringify({
databaseType: databaseType.value ?? null,
schema: tableMeta.value?.schema ?? null,
@@ -191,7 +191,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
}
function insertCopyKey(excludePrimaryKeys: boolean): string {
const rows = insertEligibleRows().map((item) => item.id);
const rows = copyStatementRowsKey(insertEligibleRows());
return JSON.stringify({
databaseType: databaseType.value ?? null,
schema: tableMeta.value?.schema ?? null,
@@ -204,6 +204,11 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
});
}
function copyStatementRowsKey(rows: RowItem[]): Array<{ id: number; data: CellValue[] }> {
// Prepared copy SQL depends on current cell values; edited rows keep the same id while their data changes.
return rows.map((item) => ({ id: item.id, data: item.data }));
}
function insertCopyCache(excludePrimaryKeys: boolean): CopyStatementCache {
return excludePrimaryKeys ? copyRowInsertWithoutPrimaryKeysCache.value : copyRowInsertCache.value;
}