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
fix(grid): reload after inserted rows save
t8y2ab6c73c6877e
diff --git a/apps/desktop/src/composables/useDataGridEditor.ts b/apps/desktop/src/composables/useDataGridEditor.tsindex 6cf8cc362b..fece519a47 100644--- a/apps/desktop/src/composables/useDataGridEditor.ts+++ b/apps/desktop/src/composables/useDataGridEditor.ts@@ -608,7 +608,7 @@ export function useDataGridEditor(options: UseDataGridEditorOptions) {async function saveChanges() {saveError.value = "";isSaving.value = true;- const shouldReloadAfterSave = deletedRows.value.size > 0;+ const shouldReloadAfterSave = newRows.value.length > 0 || deletedRows.value.size > 0;if (customSave?.value) {try {diff --git a/packages/app-tests/dataGridEditor.test.ts b/packages/app-tests/dataGridEditor.test.tsindex 848c9c787e..5926793a1c 100644--- a/packages/app-tests/dataGridEditor.test.ts+++ b/packages/app-tests/dataGridEditor.test.ts@@ -216,6 +216,56 @@ test("saving deleted rows reloads current table data", async () => {assert.deepEqual(emitted, [["reload", "SELECT id, name FROM people", "ada", "name ILIKE '%a%'", "id DESC", 50, 100]]);});+test("saving inserted rows reloads current table data", async () => {+ setActivePinia(createPinia());+ installBrowserTestGlobals();++ const result = computed(() => ({+ columns: ["id", "name"],+ rows: [[1, "Ada"] as CellValue[]],+ }));+ const rowStatusFilter = ref<"all" | "changed" | "edited" | "new" | "deleted">("all");+ const emitted: unknown[][] = [];+ const executedSql: string[] = [];++ const editor = useDataGridEditor({+ result,+ editable: computed(() => true),+ databaseType: computed(() => "postgres"),+ connectionId: computed(() => undefined),+ database: computed(() => undefined),+ tableMeta: computed(() => ({+ schema: "public",+ tableName: "people",+ columns: [column("id", true), column("name")],+ primaryKeys: ["id"],+ })),+ onExecuteSql: computed(() => async (sql: string) => {+ executedSql.push(sql);+ }),+ customSave: computed(() => undefined),+ sql: computed(() => "SELECT id, name FROM people"),+ searchText: ref("linus"),+ whereFilterInput: ref("name ILIKE '%l%'"),+ orderByInput: ref("id DESC"),+ rowStatusFilter,+ pageSize: ref(50),+ currentPage: ref(2),+ getRowItem: () => undefined,+ emit: (...args) => {+ emitted.push(args);+ },+ });++ editor.newRows.value = [[2, "Linus"]];+ await editor.saveChanges();++ assert.deepEqual(executedSql, [`INSERT INTO "public"."people" ("id", "name") VALUES (2, 'Linus');`]);+ assert.deepEqual(emitted, [+ ["reload", "SELECT id, name FROM people", "linus", "name ILIKE '%l%'", "id DESC", 50, 50],+ ]);+});+test("saving edited rows without deletes does not reload table data", async () => {setActivePinia(createPinia());installBrowserTestGlobals();