diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-01-23 20:17:09 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-01-25 11:41:56 +0100 |
commit | 79d2ca13d81462168cba7197fcd6e8de868de53a (patch) | |
tree | 4ed315804d01f444331fbbea2f9ff96b5f8fd423 /sonar-db/src/main/java/org/sonar/db | |
parent | 2e4413d7b28913c5a0ede0c43c386e9b3a13aa0d (diff) | |
download | sonarqube-79d2ca13d81462168cba7197fcd6e8de868de53a.tar.gz sonarqube-79d2ca13d81462168cba7197fcd6e8de868de53a.zip |
SONAR-8675 don't use resource_index in ProjectQgateAssociationMapper
Diffstat (limited to 'sonar-db/src/main/java/org/sonar/db')
-rw-r--r-- | sonar-db/src/main/java/org/sonar/db/qualitygate/ProjectQgateAssociationQuery.java | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/qualitygate/ProjectQgateAssociationQuery.java b/sonar-db/src/main/java/org/sonar/db/qualitygate/ProjectQgateAssociationQuery.java index 42783799e57..d69b4073f8f 100644 --- a/sonar-db/src/main/java/org/sonar/db/qualitygate/ProjectQgateAssociationQuery.java +++ b/sonar-db/src/main/java/org/sonar/db/qualitygate/ProjectQgateAssociationQuery.java @@ -26,6 +26,8 @@ import java.util.Set; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.apache.commons.lang.StringUtils; +import org.sonar.db.DatabaseUtils; +import org.sonar.db.WildcardPosition; public class ProjectQgateAssociationQuery { @@ -43,7 +45,7 @@ public class ProjectQgateAssociationQuery { private final String projectSearch; // for internal use in MyBatis - private final String projectSearchSql; + private final String projectSearchUpperLikeSql; // max results per page private final int pageSize; @@ -55,23 +57,16 @@ public class ProjectQgateAssociationQuery { this.gateId = builder.gateId; this.membership = builder.membership; this.projectSearch = builder.projectSearch; - this.projectSearchSql = projectSearchToSql(projectSearch); + if (this.projectSearch == null) { + this.projectSearchUpperLikeSql = null; + } else { + this.projectSearchUpperLikeSql = DatabaseUtils.buildLikeValue(projectSearch.toUpperCase(Locale.ENGLISH), WildcardPosition.BEFORE_AND_AFTER); + } this.pageSize = builder.pageSize; this.pageIndex = builder.pageIndex; } - private String projectSearchToSql(@Nullable String value) { - if (value == null) { - return null; - } - - return value - .replaceAll("%", "\\\\%") - .replaceAll("_", "\\\\_") - .toLowerCase(Locale.ENGLISH) + "%"; - } - public String gateId() { return gateId; } @@ -89,10 +84,6 @@ public class ProjectQgateAssociationQuery { return projectSearch; } - public String projectSearchSql() { - return projectSearchSql; - } - public int pageSize() { return pageSize; } |