import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Scopes;
import org.sonar.db.Dao;
-import org.sonar.db.DatabaseUtils;
import org.sonar.db.DbSession;
import org.sonar.db.RowNotFoundException;
if (isBlank(textQuery)) {
return null;
}
- return DatabaseUtils.buildLikeValue(textQuery.toUpperCase(Locale.ENGLISH), BEFORE_AND_AFTER);
+ return buildLikeValue(textQuery.toUpperCase(Locale.ENGLISH), BEFORE_AND_AFTER);
}
public List<ComponentDto> selectGhostProjects(DbSession session, String organizationUuid, @Nullable String query, int offset, int limit) {
- return mapper(session).selectGhostProjects(organizationUuid, queryParameterFrom(query), new RowBounds(offset, limit));
+ return mapper(session).selectGhostProjects(organizationUuid, buildUpperLikeSql(query), new RowBounds(offset, limit));
}
public long countGhostProjects(DbSession session, String organizationUuid, @Nullable String query) {
- return mapper(session).countGhostProjects(organizationUuid, queryParameterFrom(query));
+ return mapper(session).countGhostProjects(organizationUuid, buildUpperLikeSql(query));
}
/**
return mapper(dbSession).selectProjectsByNameQuery(nameQueryForSql, includeModules);
}
- @CheckForNull
- private static String queryParameterFrom(@Nullable String keyOrNameFilter) {
- if (keyOrNameFilter != null) {
- return "%" + keyOrNameFilter.toUpperCase(Locale.ENGLISH) + "%";
- }
- return null;
- }
-
public void insert(DbSession session, ComponentDto item) {
mapper(session).insert(item);
}
and p.copy_component_uuid is null
<if test="query!=null">
and (
- UPPER(p.name) like #{query}
- or UPPER(p.kee) like #{query}
+ UPPER(p.name) like #{query} ESCAPE '/'
+ or UPPER(p.kee) like #{query} ESCAPE '/'
)
</if>
</sql>
AND (p.qualifier = 'TRK' OR p.qualifier = 'BRC')
</if>
<if test="nameQuery != null">
- AND UPPER(p.name) like #{nameQuery,jdbcType=VARCHAR}
+ AND UPPER(p.name) like #{nameQuery,jdbcType=VARCHAR} ESCAPE '/'
</if>
</where>
ORDER BY p.name