fix(oceanbase): support manual transaction control in oracle mode
This commit is contained in:
15 files changed
+391
-52
No files matched your search
@@ -20,6 +20,7 @@ import {
|
||||
supportsTableImport,
|
||||
supportsTableVacuum,
|
||||
supportsTransaction,
|
||||
usesOracleStickyTransactionState,
|
||||
usesConnectionOnlyQueryTarget,
|
||||
usesTreeSchemaMode,
|
||||
schemaNodeHasLoadableName,
|
||||
@@ -160,10 +161,10 @@ describe("supportsTransaction", () => {
|
||||
expect(supportsTransaction("mysql")).toBe(true);
|
||||
expect(supportsTransaction("oracle")).toBe(true);
|
||||
expect(supportsTransaction("jdbc")).toBe(true);
|
||||
expect(supportsTransaction("oceanbase-oracle")).toBe(true);
|
||||
});
|
||||
|
||||
it("returns false for unsupported database types", () => {
|
||||
expect(supportsTransaction("oceanbase-oracle")).toBe(false);
|
||||
expect(supportsTransaction("redis")).toBe(false);
|
||||
expect(supportsTransaction("mongodb")).toBe(false);
|
||||
expect(supportsTransaction("duckdb")).toBe(false);
|
||||
@@ -198,6 +199,7 @@ describe("defaultAutoCommitForDbType", () => {
|
||||
expect(defaultAutoCommitForDbType("postgres", "manual")).toBe(false);
|
||||
expect(defaultAutoCommitForDbType("oracle", "manual")).toBe(false);
|
||||
expect(defaultAutoCommitForDbType("jdbc", "manual")).toBe(false);
|
||||
expect(defaultAutoCommitForDbType("oceanbase-oracle", "manual")).toBe(false);
|
||||
expect(defaultAutoCommitForDbType("mysql", "auto")).toBe(true);
|
||||
expect(defaultAutoCommitForDbType(undefined, "auto")).toBe(true);
|
||||
});
|
||||
@@ -208,11 +210,24 @@ describe("defaultAutoCommitForDbType", () => {
|
||||
expect(defaultAutoCommitForDbType("sqlite", "manual")).toBe(true);
|
||||
expect(defaultAutoCommitForDbType("dameng", "manual")).toBe(true);
|
||||
expect(defaultAutoCommitForDbType("clickhouse", "manual")).toBe(true);
|
||||
expect(defaultAutoCommitForDbType("oceanbase-oracle", "manual")).toBe(true);
|
||||
expect(defaultAutoCommitForDbType(undefined, "manual")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("usesOracleStickyTransactionState", () => {
|
||||
it("enables sticky manual-transaction state for Oracle family", () => {
|
||||
expect(usesOracleStickyTransactionState("oracle")).toBe(true);
|
||||
expect(usesOracleStickyTransactionState("oceanbase-oracle")).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps other databases on the generic transaction path", () => {
|
||||
expect(usesOracleStickyTransactionState("mysql")).toBe(false);
|
||||
expect(usesOracleStickyTransactionState("postgres")).toBe(false);
|
||||
expect(usesOracleStickyTransactionState("jdbc")).toBe(false);
|
||||
expect(usesOracleStickyTransactionState(undefined)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("supportsSqlInListPaste", () => {
|
||||
it("allows generic and SQL-like editors", () => {
|
||||
expect(supportsSqlInListPaste(undefined)).toBe(true);
|
||||
|
||||
@@ -257,7 +257,12 @@ export function usesPostgresLikeStructureCopy(dbType?: DatabaseType): boolean {
|
||||
return !!dbType && PG_LIKE_STRUCTURE_TYPES.has(dbType);
|
||||
}
|
||||
|
||||
const TRANSACTION_SUPPORTED_TYPES: readonly string[] = ["postgres", "mysql", "oracle", "jdbc"];
|
||||
const TRANSACTION_SUPPORTED_TYPES: readonly string[] = ["postgres", "mysql", "oracle", "jdbc", "oceanbase-oracle"];
|
||||
|
||||
/** Oracle-family databases that use the sticky manual-transaction UX. OceanBase
|
||||
* Oracle mode runs the same transaction model as Oracle, so it shares the
|
||||
* commit/rollback dirty-state behavior rather than the generic transaction path. */
|
||||
const ORACLE_STICKY_TRANSACTION_TYPES: ReadonlySet<string> = new Set(["oracle", "oceanbase-oracle"]);
|
||||
|
||||
/**
|
||||
* Returns true if the given database type supports explicit transaction control
|
||||
@@ -311,6 +316,14 @@ export function rejectsAliasReferenceInHaving(dbType?: string): boolean {
|
||||
return !!dbType && HAVING_ALIAS_REJECTED_DATABASE_TYPES.has(dbType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the database type uses Oracle's sticky manual-transaction state
|
||||
* (commit/rollback hidden until an unproven statement dirties the session).
|
||||
*/
|
||||
export function usesOracleStickyTransactionState(dbType?: string): boolean {
|
||||
return !!dbType && ORACLE_STICKY_TRANSACTION_TYPES.has(dbType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default auto-commit mode when opening a query tab for the given database type.
|
||||
* Query tabs default to auto-commit; users can explicitly switch to manual transactions.
|
||||
|
||||
Reference in new issue
Block a user