fix(editor): persist transaction mode changes

This commit is contained in:
t8y2 committed 2026-08-25 10:49:58 +08:00
1 parent 0aa18257e7
commit 2cf79b3c9f
2 files changed
+26 -1

No files matched your search

+1
View File
@@ -1687,6 +1687,7 @@ export const useQueryStore = defineStore("query", () => {
whereInput: t.whereInput, whereInput: t.whereInput,
pinned: t.pinned, pinned: t.pinned,
mode: t.mode, mode: t.mode,
autoCommit: t.autoCommit,
resultAutoSave: t.resultAutoSave, resultAutoSave: t.resultAutoSave,
structureTableName: t.structureTableName, structureTableName: t.structureTableName,
objectBrowser: t.objectBrowser, objectBrowser: t.objectBrowser,
+25 -1
View File
@@ -1,5 +1,5 @@
import { strict as assert } from "node:assert"; import { strict as assert } from "node:assert";
import { afterEach, test } from "vitest"; import { afterEach, test, vi } from "vitest";
import { createPinia, disposePinia, getActivePinia, setActivePinia } from "pinia"; import { createPinia, disposePinia, getActivePinia, setActivePinia } from "pinia";
import { isReactive, nextTick, toRaw } from "vue"; import { isReactive, nextTick, toRaw } from "vue";
import { decodeQueryResultArchive } from "../../apps/desktop/src/lib/query/queryResultArchive.ts"; import { decodeQueryResultArchive } from "../../apps/desktop/src/lib/query/queryResultArchive.ts";
@@ -323,6 +323,30 @@ test("legacy Oracle query tabs restore with the auto-commit default", async () =
} }
}); });
test("transaction mode changes persist without another tab mutation", async () => {
const restoreStorage = installMemoryStorage();
vi.useFakeTimers();
try {
setActivePinia(createPinia());
let store = useQueryStore();
const tabId = store.createTab("conn-1", "db", "Query");
await store.flushPendingPersist();
store.setAutoCommit(tabId, false);
await nextTick();
await vi.advanceTimersByTimeAsync(300);
setActivePinia(createPinia());
store = useQueryStore();
await store.initOpenTabs();
assert.equal(store.tabs.find((tab) => tab.id === tabId)?.autoCommit, false);
} finally {
vi.useRealTimers();
restoreStorage();
}
});
test("clean saved SQL tabs persist without duplicating SQL text", async () => { test("clean saved SQL tabs persist without duplicating SQL text", async () => {
const restoreStorage = installMemoryStorage(); const restoreStorage = installMemoryStorage();
try { try {