diff options
author | Jacek <jacek.poreda@sonarsource.com> | 2022-07-27 15:46:59 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-07-28 20:02:56 +0000 |
commit | 186f775d4025f1c258f371909a8f73de66cada1f (patch) | |
tree | 66aebf681c7eae994922f49018c5278df6b26041 | |
parent | 7ed0c0a19b7a0da9c6c907cab9a57a4d723dd03e (diff) | |
download | sonarqube-186f775d4025f1c258f371909a8f73de66cada1f.tar.gz sonarqube-186f775d4025f1c258f371909a8f73de66cada1f.zip |
SONAR-16504 Get schema name from connection when doing UTF-8 columns checks
-rw-r--r-- | server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/charset/PostgresCharsetHandler.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/charset/PostgresCharsetHandler.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/charset/PostgresCharsetHandler.java index 06f1d4ee69a..49cf9fdf97f 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/charset/PostgresCharsetHandler.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/charset/PostgresCharsetHandler.java @@ -30,6 +30,7 @@ import org.sonar.api.utils.MessageException; import org.sonar.api.utils.log.Loggers; import static java.lang.String.format; +import static java.util.Optional.ofNullable; import static org.apache.commons.lang.StringUtils.containsIgnoreCase; import static org.apache.commons.lang.StringUtils.isBlank; @@ -68,11 +69,12 @@ class PostgresCharsetHandler extends CharsetHandler { // Examples: // issues | key | '' // projects | name | utf8 - List<String[]> rows = getSqlExecutor().select(connection, "select table_name, column_name, collation_name " + + var schema = ofNullable(connection.getSchema()).orElse("public"); + List<String[]> rows = getSqlExecutor().select(connection, String.format("select table_name, column_name, collation_name " + "from information_schema.columns " + - "where table_schema='public' " + + "where table_schema='%s' " + "and udt_name='varchar' " + - "order by table_name, column_name", new SqlExecutor.StringsConverter(3 /* columns returned by SELECT */)); + "order by table_name, column_name", schema), new SqlExecutor.StringsConverter(3 /* columns returned by SELECT */)); Set<String> errors = new LinkedHashSet<>(); for (String[] row : rows) { if (!isBlank(row[2]) && !containsIgnoreCase(row[2], UTF8)) { |