fix(jdbc): show Oracle schemas for custom drivers

Closes #5638
This commit is contained in:
t8y2 committed 2026-08-09 18:05:23 +08:00
1 parent 8f597a0516
commit 1daaac03aa
7 files changed
+128 -16

No files matched your search

@@ -7,6 +7,7 @@ import {
connectionQueryExecutionSchema,
connectionShouldDiscoverJdbcSchemas,
connectionShouldLoadIdentifierQuote,
connectionUsesConnectionRootSchemaMode,
connectionUsesDatabaseObjectTreeMode,
effectiveDatabaseTypeForConnection,
gaussdbConnectionMode,
@@ -64,6 +65,22 @@ describe("jdbc dialect inference", () => {
).toBe("sqlserver");
});
it.each([
["jdbc:oracle:thin:@//localhost:1521/XE", "oracle"],
["jdbc:dm://localhost:5236/DAMENG", "dameng"],
] as const)("uses connection-root schemas for %s", (connectionString, dialect) => {
const connection = {
db_type: "jdbc" as const,
connection_string: connectionString,
};
expect(inferJdbcDialect(connection)).toBe(dialect);
expect(connectionUsesConnectionRootSchemaMode(connection)).toBe(true);
expect(connectionUsesDatabaseObjectTreeMode(connection)).toBe(false);
expect(connectionObjectTreeQuerySchema(connection, "DBX_TEST", "DBX_TEST")).toBe("DBX_TEST");
expect(connectionObjectTreeNodeSchema(connection, "DBX_TEST", "DBX_TEST")).toBe("DBX_TEST");
});
it("detects GaussDB-compatible JDBC connections as schema-aware", () => {
const gaussdbConnection = {
db_type: "jdbc" as const,
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { filterSchemaNamesForConnection, filterSchemaNamesForVisiblePicker, isSystemSchemaName } from "@/lib/database/visibleDatabases";
import { connectionUsesVisibleSchemaFilter, filterSchemaNamesForConnection, filterSchemaNamesForVisiblePicker, isSystemSchemaName } from "@/lib/database/visibleDatabases";
describe("visibleDatabases schema filtering", () => {
it("hides common Kingbase system schemas by default", () => {
@@ -19,6 +19,17 @@ describe("visibleDatabases schema filtering", () => {
expect(filterSchemaNamesForConnection(["DBX_TEST", "DIP", "SYSTEM"], { db_type: "oracle", database: "XE" }, "XE")).toEqual(["DBX_TEST", "DIP"]);
});
it("uses Oracle schema filtering for inferred JDBC connections", () => {
const connection = {
db_type: "jdbc" as const,
connection_string: "jdbc:oracle:thin:@//localhost:1521/XE",
username: "DBX_TEST",
};
expect(connectionUsesVisibleSchemaFilter(connection)).toBe(true);
expect(filterSchemaNamesForConnection(["ANONYMOUS", "DBX_TEST", "SYS", "SYSTEM"], connection, "")).toEqual(["DBX_TEST"]);
});
it("keeps the Dameng login schema visible while hiding default system schemas", () => {
expect(filterSchemaNamesForConnection(["APP", "SYS", "SYSDBA", "SYSDBO", "SYSAUDITOR"], { db_type: "dameng", username: "SYSDBA" }, "")).toEqual(["APP", "SYSDBA"]);
});