Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(informix): hide empty owners without losing routines

hb5bd9f41abe0a
diff --git a/agents/drivers/informix/src/main/java/com/dbx/agent/informix/InformixAgent.java b/agents/drivers/informix/src/main/java/com/dbx/agent/informix/InformixAgent.java
index 9c15922b97..62679289a1 100644
--- a/agents/drivers/informix/src/main/java/com/dbx/agent/informix/InformixAgent.java
+++ b/agents/drivers/informix/src/main/java/com/dbx/agent/informix/InformixAgent.java
@@ -24,10 +24,10 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
-import java.util.TreeSet;
public final class InformixAgent extends AbstractJdbcAgent {
private String loginOwner = "";
@@ -187,28 +187,25 @@ public final class InformixAgent extends AbstractJdbcAgent {
}
}
}
- return mergeSchemaOwners(catalogOwners, loginOwner);
+ return normalizeSchemaOwners(catalogOwners);
});
}
static String schemaCatalogSql() {
- // Informix JDBC catalogs are databases; schemas are the object owners in the current database.
+ // Informix schemas are object owners. Include routine-only owners because
+ // the same sidebar node also exposes procedures and functions.
return "SELECT owner FROM systables WHERE tabid >= 100 AND owner IS NOT NULL "
+ "UNION SELECT owner FROM sysprocedures WHERE owner IS NOT NULL ORDER BY owner";
}
- static List<String> mergeSchemaOwners(List<String> catalogOwners, String loginOwner) {
- Set<String> owners = new TreeSet<>();
+ static List<String> normalizeSchemaOwners(List<String> catalogOwners) {
+ Set<String> owners = new LinkedHashSet<>();
for (String owner : catalogOwners) {
String normalized = normalizeOwner(owner);
if (!normalized.isEmpty()) {
owners.add(normalized);
}
}
- String normalizedLoginOwner = normalizeOwner(loginOwner);
- if (!normalizedLoginOwner.isEmpty()) {
- owners.add(normalizedLoginOwner);
- }
return new ArrayList<>(owners);
}
diff --git a/agents/drivers/informix/src/test/java/com/dbx/agent/informix/InformixAgentTest.java b/agents/drivers/informix/src/test/java/com/dbx/agent/informix/InformixAgentTest.java
index 132fff3f80..8ea2422f4b 100644
--- a/agents/drivers/informix/src/test/java/com/dbx/agent/informix/InformixAgentTest.java
+++ b/agents/drivers/informix/src/test/java/com/dbx/agent/informix/InformixAgentTest.java
@@ -173,7 +173,7 @@ class InformixAgentTest {
}
@Test
- void listsSchemasFromTableRoutineAndCurrentLoginOwners() {
+ void listsSchemasFromTableAndRoutineOwnersWithoutLoginFallback() {
InformixAgent agent = new InformixAgent();
java.sql.Connection connection = JdbcMetadataSqlFake.connection();
TestSupport.setPrivateConnection(agent, connection);
@@ -181,7 +181,7 @@ class InformixAgentTest {
params.setUsername("current_owner");
agent.afterConnect(params, connection);
- Assertions.assertEquals(List.of("current_owner"), agent.listSchemas());
+ Assertions.assertEquals(List.of(), agent.listSchemas());
Assertions.assertEquals(
List.of("SELECT owner FROM systables WHERE tabid >= 100 AND owner IS NOT NULL "
@@ -189,12 +189,11 @@ class InformixAgentTest {
JdbcMetadataSqlFake.statements
);
Assertions.assertEquals(
- List.of("current_owner", "routine_owner", "table_owner"),
- InformixAgent.mergeSchemaOwners(
- List.of("table_owner", "routine_owner", "routine_owner", " "),
- "current_owner"
- )
+ List.of("table_owner", "routine_owner"),
+ InformixAgent.normalizeSchemaOwners(List.of("table_owner", "routine_owner", "routine_owner", " "))
);
+ Assertions.assertTrue(InformixAgent.schemaCatalogSql().contains("sysprocedures"));
+ Assertions.assertFalse(InformixAgent.normalizeSchemaOwners(List.of("routine_owner", " ")).contains("current_owner"));
Assertions.assertNotEquals(InformixAgent.databaseCatalogSql(), InformixAgent.schemaCatalogSql());
}