From b67b21e7324e78bab3876f460cfe426455b2d367 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Fri, 4 Nov 2016 11:28:44 +0100 Subject: [PATCH] SONAR-8089 Merge ComponentDao#selectChildren and selectDescendants --- .../sonar/server/component/ws/TreeAction.java | 46 ++-- .../filemove/FileMoveDetectionStep.java | 15 +- .../measure/ws/ComponentTreeDataLoader.java | 6 +- .../filemove/FileMoveDetectionStepTest.java | 7 +- .../org/sonar/db/component/ComponentDao.java | 64 +---- .../sonar/db/component/ComponentMapper.java | 8 +- .../db/component/ComponentTreeQuery.java | 42 ++- .../java/org/sonar/db/purge/PurgeDao.java | 15 +- .../sonar/db/component/ComponentMapper.xml | 53 ++-- .../sonar/db/component/ComponentDaoTest.java | 253 +++++------------- 10 files changed, 170 insertions(+), 339 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/TreeAction.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/TreeAction.java index 3ddb250ea0b..93db78f2ab7 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/TreeAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/TreeAction.java @@ -19,26 +19,6 @@ */ package org.sonar.server.component.ws; -import static com.google.common.base.MoreObjects.firstNonNull; -import static com.google.common.collect.FluentIterable.from; -import static com.google.common.collect.Sets.newHashSet; -import static java.lang.String.format; -import static java.util.Collections.emptyMap; -import static org.sonar.core.util.Uuids.UUID_EXAMPLE_02; -import static org.sonar.server.component.ComponentFinder.ParamNames.BASE_COMPONENT_ID_AND_KEY; -import static org.sonar.server.component.ws.ComponentDtoToWsComponent.componentDtoToWsComponent; -import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException; -import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; -import static org.sonar.server.ws.WsParameterBuilder.QualifierParameterContext.newQualifierParameterContext; -import static org.sonar.server.ws.WsParameterBuilder.createQualifiersParameter; -import static org.sonar.server.ws.WsUtils.checkRequest; -import static org.sonar.server.ws.WsUtils.writeProtobuf; -import static org.sonarqube.ws.client.component.ComponentsWsParameters.ACTION_TREE; -import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_BASE_COMPONENT_ID; -import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_BASE_COMPONENT_KEY; -import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_QUALIFIERS; -import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_STRATEGY; - import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Sets; @@ -65,6 +45,26 @@ import org.sonar.server.user.UserSession; import org.sonarqube.ws.WsComponents.TreeWsResponse; import org.sonarqube.ws.client.component.TreeWsRequest; +import static com.google.common.base.MoreObjects.firstNonNull; +import static com.google.common.collect.FluentIterable.from; +import static com.google.common.collect.Sets.newHashSet; +import static java.lang.String.format; +import static java.util.Collections.emptyMap; +import static org.sonar.core.util.Uuids.UUID_EXAMPLE_02; +import static org.sonar.server.component.ComponentFinder.ParamNames.BASE_COMPONENT_ID_AND_KEY; +import static org.sonar.server.component.ws.ComponentDtoToWsComponent.componentDtoToWsComponent; +import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException; +import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; +import static org.sonar.server.ws.WsParameterBuilder.createQualifiersParameter; +import static org.sonar.server.ws.WsParameterBuilder.QualifierParameterContext.newQualifierParameterContext; +import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.ws.WsUtils.writeProtobuf; +import static org.sonarqube.ws.client.component.ComponentsWsParameters.ACTION_TREE; +import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_BASE_COMPONENT_ID; +import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_BASE_COMPONENT_KEY; +import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_QUALIFIERS; +import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_STRATEGY; + public class TreeAction implements ComponentsWsAction { private static final int MAX_SIZE = 500; private static final int QUERY_MINIMUM_LENGTH = 3; @@ -158,13 +158,13 @@ public class TreeAction implements ComponentsWsAction { int total; switch (treeWsRequest.getStrategy()) { case CHILDREN_STRATEGY: - components = dbClient.componentDao().selectChildren(dbSession, query); - total = dbClient.componentDao().countChildren(dbSession, query); + components = dbClient.componentDao().selectDescendants(dbSession, query); + total = components.size(); break; case LEAVES_STRATEGY: case ALL_STRATEGY: components = dbClient.componentDao().selectDescendants(dbSession, query); - total = dbClient.componentDao().countDescendants(dbSession, query); + total = components.size(); break; default: throw new IllegalStateException("Unknown component tree strategy"); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/filemove/FileMoveDetectionStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/filemove/FileMoveDetectionStep.java index 5ffd9591cd5..38e1f2ab914 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/filemove/FileMoveDetectionStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/filemove/FileMoveDetectionStep.java @@ -41,8 +41,11 @@ import org.sonar.core.hash.SourceLinesHashesComputer; import org.sonar.core.util.CloseableIterator; import org.sonar.db.DbClient; import org.sonar.db.DbSession; +import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTreeQuery; +import org.sonar.db.component.ComponentTreeQuery.Strategy; import org.sonar.db.source.FileSourceDto; +import org.sonar.server.computation.task.projectanalysis.analysis.Analysis; import org.sonar.server.computation.task.projectanalysis.analysis.AnalysisMetadataHolder; import org.sonar.server.computation.task.projectanalysis.component.Component; import org.sonar.server.computation.task.projectanalysis.component.CrawlerDepthLimit; @@ -50,21 +53,18 @@ import org.sonar.server.computation.task.projectanalysis.component.DepthTraversa import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolder; import org.sonar.server.computation.task.projectanalysis.component.TypeAwareVisitorAdapter; import org.sonar.server.computation.task.projectanalysis.filemove.FileSimilarity.File; -import org.sonar.server.computation.task.projectanalysis.analysis.Analysis; import org.sonar.server.computation.task.projectanalysis.source.SourceLinesRepository; import org.sonar.server.computation.task.step.ComputationStep; import static com.google.common.base.Splitter.on; import static com.google.common.collect.FluentIterable.from; import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; import static org.sonar.server.computation.task.projectanalysis.component.ComponentVisitor.Order.POST_ORDER; public class FileMoveDetectionStep implements ComputationStep { protected static final int MIN_REQUIRED_SCORE = 85; private static final Logger LOG = Loggers.get(FileMoveDetectionStep.class); private static final List FILE_QUALIFIERS = asList(Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE); - private static final List SORT_FIELDS = singletonList("name"); private static final Splitter LINES_HASHES_SPLITTER = on('\n'); private final AnalysisMetadataHolder analysisMetadataHolder; @@ -152,15 +152,14 @@ public class FileMoveDetectionStep implements ComputationStep { try (DbSession dbSession = dbClient.openSession(false)) { // FIXME no need to use such a complex query, joining on SNAPSHOTS and retrieving all column of table PROJECTS, replace with dedicated // mapper method - return from(dbClient.componentDao().selectDescendants( + List componentDtos = dbClient.componentDao().selectDescendants( dbSession, ComponentTreeQuery.builder() .setBaseUuid(rootHolder.getRoot().getUuid()) .setQualifiers(FILE_QUALIFIERS) - .setSortFields(SORT_FIELDS) - .setPageSize(Integer.MAX_VALUE) - .setPage(1) - .build())) + .setStrategy(Strategy.LEAVES) + .build()); + return from(componentDtos) .transform(componentDto -> new DbComponent(componentDto.getId(), componentDto.key(), componentDto.uuid(), componentDto.path())) .uniqueIndex(DbComponent::getKey); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeDataLoader.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeDataLoader.java index 8a2d059c215..04f5c44c397 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeDataLoader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeDataLoader.java @@ -172,13 +172,13 @@ public class ComponentTreeDataLoader { switch (strategy) { case CHILDREN_STRATEGY: return new ComponentDtosAndTotal( - dbClient.componentDao().selectChildren(dbSession, dbQuery), - dbClient.componentDao().countChildren(dbSession, dbQuery)); + dbClient.componentDao().selectDescendants(dbSession, dbQuery), + 0); case LEAVES_STRATEGY: case ALL_STRATEGY: return new ComponentDtosAndTotal( dbClient.componentDao().selectDescendants(dbSession, dbQuery), - dbClient.componentDao().countDescendants(dbSession, dbQuery)); + 0); default: throw new IllegalStateException("Unknown component tree strategy"); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/filemove/FileMoveDetectionStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/filemove/FileMoveDetectionStepTest.java index f19049bcabc..15bb327294c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/filemove/FileMoveDetectionStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/filemove/FileMoveDetectionStepTest.java @@ -44,11 +44,11 @@ import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTreeQuery; import org.sonar.db.source.FileSourceDao; import org.sonar.db.source.FileSourceDto; +import org.sonar.server.computation.task.projectanalysis.analysis.Analysis; import org.sonar.server.computation.task.projectanalysis.analysis.AnalysisMetadataHolderRule; -import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule; import org.sonar.server.computation.task.projectanalysis.component.Component; import org.sonar.server.computation.task.projectanalysis.component.ReportComponent; -import org.sonar.server.computation.task.projectanalysis.analysis.Analysis; +import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule; import org.sonar.server.computation.task.projectanalysis.source.SourceLinesRepositoryRule; import static com.google.common.base.Joiner.on; @@ -287,9 +287,6 @@ public class FileMoveDetectionStepTest { ComponentTreeQuery query = captor.getValue(); assertThat(query.getBaseUuid()).isEqualTo(PROJECT.getUuid()); - assertThat(query.getPage()).isEqualTo(1); - assertThat(query.getPageSize()).isEqualTo(Integer.MAX_VALUE); - assertThat(query.getSqlSort()).isEqualTo("LOWER(p.name) ASC, p.name ASC"); assertThat(query.getQualifiers()).containsOnly(FILE, UNIT_TEST_FILE); } diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java index fd5fe9dc652..62c4652b05d 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java @@ -34,15 +34,12 @@ import org.apache.ibatis.session.RowBounds; 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; -import org.sonar.db.WildcardPosition; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.collect.Maps.newHashMapWithExpectedSize; import static java.util.Collections.emptyList; -import static org.sonar.api.utils.Paging.offset; import static org.sonar.db.DatabaseUtils.executeLargeInputs; import static org.sonar.db.DatabaseUtils.executeLargeUpdates; @@ -167,42 +164,7 @@ public class ComponentDao implements Dao { } /** - * Select the children of a base component, given by its UUID. The components that are not present in last - * analysis are ignored. - * - * An empty list is returned if the base component does not exist or if the base component is a leaf. - */ - public List selectChildren(DbSession dbSession, ComponentTreeQuery query) { - Optional componentOpt = selectByUuid(dbSession, query.getBaseUuid()); - if (!componentOpt.isPresent()) { - return emptyList(); - } - ComponentDto component = componentOpt.get(); - RowBounds rowBounds = new RowBounds(offset(query.getPage(), query.getPageSize()), query.getPageSize()); - return mapper(dbSession).selectChildren(query, uuidPathForChildrenQuery(component), rowBounds); - } - - /** - * Count the children of a base component, given by its UUID. The components that are not present in last - * analysis are ignored. - * - * Zero is returned if the base component does not exist or if the base component is a leaf. - */ - public int countChildren(DbSession dbSession, ComponentTreeQuery query) { - Optional componentOpt = selectByUuid(dbSession, query.getBaseUuid()); - if (!componentOpt.isPresent()) { - return 0; - } - ComponentDto component = componentOpt.get(); - return mapper(dbSession).countChildren(query, uuidPathForChildrenQuery(component)); - } - - private static String uuidPathForChildrenQuery(ComponentDto component) { - return component.getUuidPath() + component.uuid() + "."; - } - - /** - * Select the descendants of a base component, given by its UUID. The components that are not present in last + * Select the children or the leaves of a base component, given by its UUID. The components that are not present in last * analysis are ignored. * * An empty list is returned if the base component does not exist or if the base component is a leaf. @@ -210,30 +172,10 @@ public class ComponentDao implements Dao { public List selectDescendants(DbSession dbSession, ComponentTreeQuery query) { Optional componentOpt = selectByUuid(dbSession, query.getBaseUuid()); if (!componentOpt.isPresent()) { - return Collections.emptyList(); - } - ComponentDto component = componentOpt.get(); - RowBounds rowBounds = new RowBounds(offset(query.getPage(), query.getPageSize()), query.getPageSize()); - return mapper(dbSession).selectDescendants(query, uuidPathForDescendantsQuery(component), rowBounds); - } - - /** - * Count the descendants of a base component, given by its UUID. The components that are not present in last - * analysis are ignored. - * - * Zero is returned if the base component does not exist or if the base component is a leaf. - */ - public int countDescendants(DbSession dbSession, ComponentTreeQuery query) { - Optional componentOpt = selectByUuid(dbSession, query.getBaseUuid()); - if (!componentOpt.isPresent()) { - return 0; + return emptyList(); } ComponentDto component = componentOpt.get(); - return mapper(dbSession).countDescendants(query, uuidPathForDescendantsQuery(component)); - } - - private static String uuidPathForDescendantsQuery(ComponentDto component) { - return DatabaseUtils.buildLikeValue(component.getUuidPath() + component.uuid() + ".", WildcardPosition.AFTER); + return mapper(dbSession).selectDescendants(query, query.getUuidPath(component)); } public ComponentDto selectOrFailByKey(DbSession session, String key) { diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java index 027a67fe5a1..7e41d5c97b4 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java @@ -64,13 +64,7 @@ public interface ComponentMapper { List selectAncestors(@Param("query") ComponentTreeQuery query, @Param("baseUuidPathLike") String baseUuidPathLike); - List selectChildren(@Param("query") ComponentTreeQuery query, @Param("baseUuidPath") String baseUuidPath, RowBounds rowBounds); - - int countChildren(@Param("query") ComponentTreeQuery query, @Param("baseUuidPath") String baseUuidPath); - - List selectDescendants(@Param("query") ComponentTreeQuery query, @Param("baseUuidPathLike") String baseUuidPathLike, RowBounds rowBounds); - - int countDescendants(@Param("query") ComponentTreeQuery query, @Param("baseUuidPathLike") String baseUuidPathLike); + List selectDescendants(@Param("query") ComponentTreeQuery query, @Param("baseUuidPath") String baseUuidPath); /** * Return all project (PRJ/TRK) uuids diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java index b987ff47928..c8f47f6cd75 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java @@ -28,6 +28,7 @@ import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import org.sonar.db.WildcardPosition; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.collect.Lists.newArrayList; @@ -37,6 +38,11 @@ import static org.sonar.db.DatabaseUtils.buildLikeValue; import static org.sonar.db.WildcardPosition.AFTER; public class ComponentTreeQuery { + + public enum Strategy { + CHILDREN, LEAVES + } + @CheckForNull private final String nameOrKeyQuery; // SONAR-7681 a public implementation of List must be used in MyBatis - potential concurrency exceptions otherwise @@ -49,6 +55,7 @@ public class ComponentTreeQuery { private final String baseUuid; private final String sqlSort; private final String direction; + private final Strategy strategy; private ComponentTreeQuery(Builder builder) { this.nameOrKeyQuery = builder.nameOrKeyQuery; @@ -56,8 +63,9 @@ public class ComponentTreeQuery { this.page = builder.page; this.pageSize = builder.pageSize; this.baseUuid = builder.baseUuid; + this.strategy = requireNonNull(builder.strategy); this.direction = builder.asc ? "ASC" : "DESC"; - this.sqlSort = sortFieldsToSqlSort(builder.sortFields, direction); + this.sqlSort = builder.sortFields != null ? sortFieldsToSqlSort(builder.sortFields, direction) : null; } public Collection getQualifiers() { @@ -74,10 +82,12 @@ public class ComponentTreeQuery { return nameOrKeyQuery == null ? null : buildLikeValue(nameOrKeyQuery, AFTER).toLowerCase(Locale.ENGLISH); } + @Deprecated public Integer getPage() { return page; } + @Deprecated public Integer getPageSize() { return pageSize; } @@ -86,18 +96,36 @@ public class ComponentTreeQuery { return baseUuid; } + public Strategy getStrategy() { + return strategy; + } + + @Deprecated public String getSqlSort() { return sqlSort; } + @Deprecated public String getDirection() { return direction; } + public String getUuidPath(ComponentDto component) { + switch (strategy) { + case CHILDREN: + return component.getUuidPath() + component.uuid() + "."; + case LEAVES: + return buildLikeValue(component.getUuidPath() + component.uuid() + ".", WildcardPosition.AFTER); + default: + throw new IllegalArgumentException("Unknown strategy : " + strategy); + } + } + public static Builder builder() { return new Builder(); } + @Deprecated private static String sortFieldsToSqlSort(List sortFields, String direction) { return sortFields .stream() @@ -117,6 +145,7 @@ public class ComponentTreeQuery { private String baseUuid; private List sortFields; private boolean asc = true; + private Strategy strategy; private Builder() { // private constructor @@ -124,7 +153,6 @@ public class ComponentTreeQuery { public ComponentTreeQuery build() { requireNonNull(baseUuid); - requireNonNull(sortFields); return new ComponentTreeQuery(this); } @@ -138,11 +166,13 @@ public class ComponentTreeQuery { return this; } + @Deprecated public Builder setPage(int page) { this.page = page; return this; } + @Deprecated public Builder setPageSize(int pageSize) { this.pageSize = pageSize; return this; @@ -153,18 +183,26 @@ public class ComponentTreeQuery { return this; } + public Builder setStrategy(Strategy strategy) { + this.strategy = requireNonNull(strategy); + return this; + } + + @Deprecated public Builder setSortFields(List sorts) { checkArgument(sorts != null && !sorts.isEmpty()); this.sortFields = sorts; return this; } + @Deprecated public Builder setAsc(boolean asc) { this.asc = asc; return this; } } + @Deprecated private static class SortFieldToSqlSortFieldFunction implements Function { private static final String PATTERN = "LOWER(p.%1$s) %2$s, p.%1$s %2$s"; diff --git a/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java b/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java index 0b5a2f48700..aba3ff7e704 100644 --- a/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java +++ b/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java @@ -34,6 +34,7 @@ import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDao; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTreeQuery; +import org.sonar.db.component.ComponentTreeQuery.Strategy; import static java.util.Collections.emptyList; import static org.sonar.api.utils.DateUtils.dateToLong; @@ -45,7 +46,6 @@ import static org.sonar.db.DatabaseUtils.executeLargeInputs; public class PurgeDao implements Dao { private static final Logger LOG = Loggers.get(PurgeDao.class); private static final String[] UNPROCESSED_STATUS = new String[] {"U"}; - private static final List UUID_FIELD_SORT = Collections.singletonList("uuid"); private final ComponentDao componentDao; private final System2 system2; @@ -112,9 +112,10 @@ public class PurgeDao implements Dao { List componentWithoutHistoricalDataUuids = componentDao .selectDescendants( dbSession, - newComponentTreeQuery() + ComponentTreeQuery.builder() .setBaseUuid(rootUuid) .setQualifiers(Arrays.asList(scopesWithoutHistoricalData)) + .setStrategy(Strategy.LEAVES) .build()) .stream().map(ComponentDto::uuid) .collect(Collectors.toList()); @@ -122,16 +123,6 @@ public class PurgeDao implements Dao { purgeCommands.deleteComponentMeasures(analysisUuids, componentWithoutHistoricalDataUuids); } - /** - * Creates a new ComponentTreeQuery.Builder with properties that don't matter here but are mandatory populated. - */ - private static ComponentTreeQuery.Builder newComponentTreeQuery() { - return ComponentTreeQuery.builder() - .setPage(1) - .setPageSize(Integer.MAX_VALUE) - .setSortFields(UUID_FIELD_SORT); - } - private void purgeDisabledComponents(DbSession session, Collection uuids, PurgeListener listener) { PurgeMapper mapper = mapper(session); executeLargeInputs(uuids, diff --git a/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml b/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml index 52dd7c88206..8a3aa4973a9 100644 --- a/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml @@ -331,29 +331,30 @@ order by ${query.sqlSort} - - select - - order by ${query.sqlSort} + - - - + from projects p inner join projects base on base.project_uuid = p.project_uuid and base.uuid = #{query.baseUuid} - where - p.enabled = ${_true} - and p.uuid_path = #{baseUuidPath} - + + + + and p.uuid_path = #{baseUuidPath} + + + and p.uuid_path like #{baseUuidPath} ESCAPE '/' + + + + - + + and p.enabled = ${_true} and p.qualifier in @@ -379,28 +380,6 @@ - - - - - - - from projects p - inner join projects base on base.project_uuid=p.project_uuid and base.uuid = #{query.baseUuid} - where - p.enabled = ${_true} - and p.uuid_path like #{baseUuidPathLike} ESCAPE '/' - - -