fix(table-paste): surface first batch paste error

Closes #4832
This commit is contained in:
t8y2 committed 2026-08-23 16:24:19 +00:00
1 parent e1eb44f626
commit 72bb880ee7
6 files changed
+74 -10

No files matched your search

@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { tableClipboardMatchesTarget, tableClipboardMenuState, tableClipboardSourceContext } from "@/lib/table/tableClipboard";
import { tableClipboardMatchesTarget, tableClipboardMenuState, tableClipboardSourceContext, tablePasteFeedback } from "@/lib/table/tableClipboard";
describe("table clipboard contexts", () => {
const source = { connectionId: "source", database: "app", schema: "public" };
@@ -23,4 +23,11 @@ describe("table clipboard contexts", () => {
expect(tableClipboardMenuState([sourceTable], targetTable)).toBe("copy");
expect(tableClipboardMenuState([sourceTable], targetTable, true)).toBe("copy-and-paste");
});
it("keeps batch feedback bounded to the first paste error", () => {
const firstError = { code: "permission-denied" };
const feedback = tablePasteFeedback(0, 3, firstError);
expect(feedback).toEqual({ successCount: 0, failedCount: 3, firstError });
});
});
@@ -20,6 +20,21 @@ export interface TableDataCopyColumnOptions {
sqlserverIdentityInsert: boolean;
}
export interface TablePasteFeedback {
successCount: number;
failedCount: number;
firstError: unknown;
}
/** Keep batch paste feedback bounded while preserving the first actionable error. */
export function tablePasteFeedback(successCount: number, failedCount: number, firstError: unknown): TablePasteFeedback {
return {
successCount,
failedCount,
firstError,
};
}
function normalizeSchema(schema: string | null | undefined): string {
return schema?.trim() ?? "";
}