mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-20 00:17:44 +00:00
fix(jdbc): fall back to jdbc schemas without all_users
This commit is contained in:
@@ -3389,6 +3389,7 @@ public final class DbxJdbcPlugin {
|
||||
return rs.getString(1);
|
||||
}
|
||||
}
|
||||
} catch (SQLException ignored) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -3402,6 +3403,7 @@ public final class DbxJdbcPlugin {
|
||||
return rs.getString(1);
|
||||
}
|
||||
}
|
||||
} catch (SQLException ignored) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -3416,8 +3418,18 @@ public final class DbxJdbcPlugin {
|
||||
result.add(name);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} catch (SQLException e) {
|
||||
try (ResultSet rs = conn.getMetaData().getSchemas()) {
|
||||
while (rs.next()) {
|
||||
String schema = rs.getString("TABLE_SCHEM");
|
||||
if (schema != null && !schema.isBlank()) {
|
||||
result.add(schema);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static JsonNode oracleListTables(Connection conn, String owner) throws SQLException {
|
||||
|
||||
@@ -2730,6 +2730,28 @@ final class DbxJdbcPluginTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void oracleListSchemasFallsBackToJdbcSchemasWhenAllUsersIsMissing() throws Exception {
|
||||
Method method = DbxJdbcPlugin.class.getDeclaredMethod("oracleListSchemas", Connection.class);
|
||||
method.setAccessible(true);
|
||||
|
||||
try (Connection conn = DriverManager.getConnection("jdbc:h2:mem:dbx_oracle_no_all_users;DB_CLOSE_DELAY=-1", "sa", "")) {
|
||||
conn.createStatement().execute("CREATE SCHEMA DM6_TEST_SCHEMA");
|
||||
|
||||
JsonNode result = (JsonNode) method.invoke(null, conn);
|
||||
assertFalse(result.isNull());
|
||||
assertEquals(true, result.isArray());
|
||||
boolean found = false;
|
||||
for (JsonNode node : result) {
|
||||
if ("DM6_TEST_SCHEMA".equalsIgnoreCase(node.asText())) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertEquals(true, found);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void oracleEffectiveSchemaUsesExactOwnerBeforeUppercaseFallback() throws Exception {
|
||||
Method method = DbxJdbcPlugin.class.getDeclaredMethod("oracleEffectiveSchema", Connection.class, String.class);
|
||||
|
||||
Reference in New Issue
Block a user