feat(oracle): support manual query transactions

This commit is contained in:
t8y2 committed 2026-08-21 01:05:59 +08:00
1 parent a7edb8f8db
commit b5d3343f9a
22 files changed
+1011 -99

No files matched your search

@@ -3,6 +3,7 @@ import { connectionNamespaceCreationTarget, databaseNodeNamespaceCreationTarget
import { editableDatabasePropertyGroups, editableSchemaPropertyGroups } from "@/lib/database/databasePropertyEditing";
import { buildGetDatabaseCommentSql } from "@/lib/database/dbAdminSql";
import {
defaultAutoCommitForDbType,
isSchemaAware,
supportsConnectionScopedQueryExecution,
supportsConnectionDatabaseBrowser,
@@ -89,6 +90,7 @@ describe("supportsTransaction", () => {
it("returns true for supported database types", () => {
expect(supportsTransaction("postgres")).toBe(true);
expect(supportsTransaction("mysql")).toBe(true);
expect(supportsTransaction("oracle")).toBe(true);
});
it("returns false for unsupported database types", () => {
@@ -101,7 +103,6 @@ describe("supportsTransaction", () => {
expect(supportsTransaction("sqlite")).toBe(false);
expect(supportsTransaction("clickhouse")).toBe(false);
expect(supportsTransaction("sqlserver")).toBe(false);
expect(supportsTransaction("oracle")).toBe(false);
expect(supportsTransaction("dameng")).toBe(false);
expect(supportsTransaction("rqlite")).toBe(false);
expect(supportsTransaction("agent")).toBe(false);
@@ -112,6 +113,19 @@ describe("supportsTransaction", () => {
});
});
describe("defaultAutoCommitForDbType", () => {
it("defaults Oracle query tabs to manual transactions", () => {
expect(defaultAutoCommitForDbType("oracle")).toBe(false);
});
it("defaults other databases to auto-commit", () => {
expect(defaultAutoCommitForDbType("mysql")).toBe(true);
expect(defaultAutoCommitForDbType("postgres")).toBe(true);
expect(defaultAutoCommitForDbType("dameng")).toBe(true);
expect(defaultAutoCommitForDbType(undefined)).toBe(true);
});
});
describe("supportsSqlInListPaste", () => {
it("allows generic and SQL-like editors", () => {
expect(supportsSqlInListPaste(undefined)).toBe(true);
@@ -42,6 +42,7 @@ export interface SavedOpenTab {
whereInput?: string;
pinned?: boolean;
mode?: QueryTab["mode"];
autoCommit?: boolean;
mqTenant?: string;
mqInitialTab?: QueryTab["mqInitialTab"];
nacosNamespace?: string;
@@ -117,6 +118,7 @@ export function serializeOpenTabs(tabs: QueryTab[]): SavedOpenTab[] {
...(tab.whereInput !== undefined ? { whereInput: tab.whereInput } : {}),
pinned: tab.pinned,
mode: tab.mode,
...(tab.mode === "query" && tab.autoCommit !== undefined ? { autoCommit: tab.autoCommit } : {}),
...(tab.mqTenant !== undefined ? { mqTenant: tab.mqTenant } : {}),
...(tab.mqInitialTab !== undefined ? { mqInitialTab: tab.mqInitialTab } : {}),
...(tab.nacosNamespace !== undefined ? { nacosNamespace: tab.nacosNamespace } : {}),
@@ -229,7 +229,7 @@ export function usesPostgresLikeStructureCopy(dbType?: DatabaseType): boolean {
return !!dbType && PG_LIKE_STRUCTURE_TYPES.has(dbType);
}
const TRANSACTION_SUPPORTED_TYPES: readonly string[] = ["postgres", "mysql"];
const TRANSACTION_SUPPORTED_TYPES: readonly string[] = ["postgres", "mysql", "oracle"];
/**
* Returns true if the given database type supports explicit transaction control
@@ -238,3 +238,11 @@ const TRANSACTION_SUPPORTED_TYPES: readonly string[] = ["postgres", "mysql"];
export function supportsTransaction(dbType?: string): boolean {
return !!dbType && TRANSACTION_SUPPORTED_TYPES.includes(dbType);
}
/**
* Default auto-commit mode when opening a query tab for the given database type.
* Oracle defaults to manual transactions so edits require an explicit Commit.
*/
export function defaultAutoCommitForDbType(dbType?: string): boolean {
return dbType !== "oracle";
}