diff --git a/apps/desktop/src/lib/__tests__/database/visibleDatabases.spec.ts b/apps/desktop/src/lib/__tests__/database/visibleDatabases.spec.ts index 907f76fb97..d38085052f 100644 --- a/apps/desktop/src/lib/__tests__/database/visibleDatabases.spec.ts +++ b/apps/desktop/src/lib/__tests__/database/visibleDatabases.spec.ts @@ -55,6 +55,35 @@ describe("visibleDatabases schema filtering", () => { ).toEqual(["sys_catalog"]); }); + it("applies the schema filter stored under the empty key to the single-db sentinel", () => { + const connection = { + db_type: "oceanbase-oracle" as const, + username: "sys@obtest", + visible_schemas: { "": ["APP", "SYS"] }, + }; + + expect(filterSchemaNamesForConnection(["APP", "SYS", "MDSYS", "REPORT"], connection, "_")).toEqual(["APP", "SYS"]); + }); + + it("hides schemas unchecked in the filter when addressed via the sentinel key", () => { + const connection = { + db_type: "oceanbase-oracle" as const, + username: "sys@obtest", + visible_schemas: { "": ["APP"] }, + }; + + expect(filterSchemaNamesForConnection(["APP", "SYS", "REPORT"], connection, "_")).toEqual(["APP"]); + }); + + it("keeps the login schema visible for user@tenant usernames", () => { + expect( + filterSchemaNamesForVisiblePicker(["APP", "MDSYS", "SYS", "SYSTEM"], { + db_type: "oceanbase-oracle", + username: "sys@obtest", + }), + ).toEqual(["APP", "SYS"]); + }); + it("matches prefix-based system schema rules", () => { expect(isSystemSchemaName("kingbase", "xlog_record_read")).toBe(true); expect(isSystemSchemaName("opengauss", "dbe_pldeveloper")).toBe(true); diff --git a/apps/desktop/src/lib/database/visibleDatabases.ts b/apps/desktop/src/lib/database/visibleDatabases.ts index 1def27e451..7f7d0c0a6f 100644 --- a/apps/desktop/src/lib/database/visibleDatabases.ts +++ b/apps/desktop/src/lib/database/visibleDatabases.ts @@ -247,8 +247,15 @@ export function filterDatabaseNamesForVisiblePicker(databaseNames: string[], con export function filterSchemaNamesForVisiblePicker(schemaNames: string[], connection: VisibleDatabaseConnection | undefined, options?: SchemaFilterOptions): string[] { if (schemaFilterShowSystemSchemas(connection, options)) return schemaNames; const currentSchema = connection?.username?.trim().toLowerCase(); + // OceanBase Oracle logins embed the tenant in the username ("user@tenant"); + // the schema equals the user part, so keep the login schema visible in both + // forms instead of hiding it behind a system-schema name (#8145). + const currentUserPart = currentSchema?.split("@")[0]; const databaseType = effectiveDatabaseTypeForConnection(connection); - return schemaNames.filter((name) => name.toLowerCase() === currentSchema || !isSystemSchemaName(databaseType, name)); + return schemaNames.filter((name) => { + const normalized = name.toLowerCase(); + return normalized === currentSchema || normalized === currentUserPart || !isSystemSchemaName(databaseType, name); + }); } export function connectionUsesVisibleSchemaFilter(connection: VisibleDatabaseConnection | undefined): boolean { @@ -261,7 +268,12 @@ export function visibleSchemaFilterIsEnabled(visibleSchemas: Record visible.has(name)); }