fix(editor): route grid edits through manual txn session

This commit is contained in:
zipg authored and GitHub committed 2026-09-03 10:27:41 +08:00
1 parent 321674c4dc
commit e2eb481b8a
6 files changed
+95 -4

No files matched your search

@@ -161,6 +161,20 @@ describe("queryStore Oracle manual-transaction sticky state", () => {
expect(tab.oracleTxnPossiblyDirty).toBe(true);
});
it("marks an Oracle manual session dirty when the result grid dispatches a mutation", async () => {
mocks.executeInManualTransaction.mockResolvedValue(cleanSelect());
const { useQueryStore } = await import("@/stores/queryStore");
const store = useQueryStore();
const tabId = await setupManualTab(store);
await store.executeTabSql(tabId, "SELECT * FROM EMP");
store.markManualTransactionDirty(tabId);
const tab = store.tabs.find((item) => item.id === tabId)!;
expect(tab.oracleTxnPossiblyDirty).toBe(true);
});
it("never clears the sticky state after a later read (UPDATE -> SELECT)", async () => {
mocks.executeInManualTransaction.mockResolvedValueOnce(dirtyUpdate()).mockResolvedValueOnce(cleanSelect());
@@ -332,6 +346,7 @@ describe("queryStore Oracle manual-transaction sticky state", () => {
store.setAutoCommit(tabId, false);
await store.executeTabSql(tabId, "SELECT 1");
store.markManualTransactionDirty(tabId);
const tab = store.tabs.find((item) => item.id === tabId)!;
// No classificationSql was sent and no Oracle sticky state exists.
+8
View File
@@ -3429,6 +3429,13 @@ export const useQueryStore = defineStore("query", () => {
}
}
function markManualTransactionDirty(id: string) {
const tab = tabs.value.find((item) => item.id === id);
if (!tab?.txnSessionId) return;
const dbType = effectiveDatabaseTypeForConnection(useConnectionStore().getConfig(tab.connectionId));
if (dbType === "oracle") tab.oracleTxnPossiblyDirty = true;
}
/** Reset only the Oracle sticky-dirty bit. Used when a session continues but
* the old dirty state must be discarded (e.g. idle-expiry recovery where the
* replacement session starts fresh). Full session cleanup goes through
@@ -7101,6 +7108,7 @@ export const useQueryStore = defineStore("query", () => {
updateObjectBrowserViewport,
updateNacosConfigEditorViewport,
setAutoCommit,
markManualTransactionDirty,
commitTransaction,
rollbackTransaction,
renameTab,