Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -261,22 +261,36 @@ private static String getDbUser(@NonNull ConnectionConfig connectionConfig) {
return username;
}

public static String getSchema(@NonNull String schema, @NonNull DialectType dialectType) {
switch (dialectType) {
case OB_ORACLE:
case ORACLE:
return "\"" + schema + "\"";
case OB_MYSQL:
case MYSQL:
case ODP_SHARDING_OB_MYSQL:
return schema;
default:
return null;
}
}

public static String getDefaultSchema(@NonNull ConnectionConfig connectionConfig) {
String defaultSchema = connectionConfig.getDefaultSchema();
switch (connectionConfig.getDialectType()) {
case OB_ORACLE:
case ORACLE:
if (StringUtils.isNotEmpty(defaultSchema)) {
return "\"" + defaultSchema + "\"";
return getSchema(defaultSchema, connectionConfig.getDialectType());
}
return "\"" + getDbUser(connectionConfig) + "\"";
return getSchema(getDbUser(connectionConfig), connectionConfig.getDialectType());
case OB_MYSQL:
case MYSQL:
case ODP_SHARDING_OB_MYSQL:
if (StringUtils.isNotEmpty(defaultSchema)) {
return defaultSchema;
return getSchema(defaultSchema, connectionConfig.getDialectType());
}
return OdcConstants.MYSQL_DEFAULT_SCHEMA;
return getSchema(OdcConstants.MYSQL_DEFAULT_SCHEMA, connectionConfig.getDialectType());
default:
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public List<CheckViolation> check(@NotNull Long environmentId, @NonNull String d
Environment env = this.environmentService.detail(environmentId);
List<Rule> rules = this.ruleService.list(env.getRulesetId(), QueryRuleMetadataParams.builder().build());
OBConsoleDataSourceFactory factory = new OBConsoleDataSourceFactory(config, true, false);
factory.resetSchema(origin -> databaseName);
factory.resetSchema(origin -> OBConsoleDataSourceFactory.getSchema(databaseName, config.getDialectType()));
SqlCheckContext checkContext = new SqlCheckContext((long) sqls.size());
try (SingleConnectionDataSource dataSource = (SingleConnectionDataSource) factory.getDataSource()) {
JdbcTemplate jdbc = new JdbcTemplate(dataSource);
Expand Down