fix(kingbase): prioritize selected schema search path
This commit is contained in:
1 parent
2b5aaa2a54
commit
ece47c85d6
9 files changed
+146
-72
No files matched your search
@@ -542,7 +542,10 @@ public final class KingbaseAgent extends PostgresLikeAgent {
|
||||
|
||||
@Override
|
||||
public String setSchemaSQL(String schema) {
|
||||
return "SET search_path TO " + JdbcIdentifiers.INSTANCE.doubleQuote(effectiveSchema(schema));
|
||||
// Kingbase searches sys_catalog implicitly before user schemas unless it
|
||||
// is listed explicitly. Put it after the selected schema so business
|
||||
// tables named like system tables (for example sys_config) win.
|
||||
return "SET search_path TO " + JdbcIdentifiers.INSTANCE.doubleQuote(effectiveSchema(schema)) + ", sys_catalog";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,6 +45,14 @@ class KingbaseAgentTest extends JdbcFakeExecutionBehaviorTest {
|
||||
Assertions.assertEquals("jdbc:kingbase8://{host}:{port}/{database}", agent.getProfile().getUrlTemplate());
|
||||
}
|
||||
|
||||
@Test
|
||||
void schemaSwitchPlacesSysCatalogAfterSelectedSchema() {
|
||||
KingbaseAgent agent = new KingbaseAgent();
|
||||
|
||||
Assertions.assertEquals("SET search_path TO \"app\", sys_catalog", agent.setSchemaSQL("app"));
|
||||
Assertions.assertEquals("SET search_path TO \"app\"\"prod\", sys_catalog", agent.setSchemaSQL("app\"prod"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void mysqlCompatListDatabasesUsesCurrentDatabase() {
|
||||
List<String> sql = new ArrayList<>();
|
||||
|
||||
Reference in new issue
Block a user