diff options
3 files changed, 31 insertions, 10 deletions
diff --git a/sonar-core/src/main/resources/org/sonar/core/issue/IssueMapper.xml b/sonar-core/src/main/resources/org/sonar/core/issue/IssueMapper.xml index b350c948c52..4005fc2faba 100644 --- a/sonar-core/src/main/resources/org/sonar/core/issue/IssueMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/issue/IssueMapper.xml @@ -90,14 +90,21 @@ </if> <where> <if test="componentKeys.size() > 0"> - and root.islast=true - and ((s.root_snapshot_id=root.id and s.path LIKE concat(root.path, root.id, '.%')) or s.id=root.id) - and root.project_id=p.id - and i.resource_id=s.project_id and p.enabled=true and p.kee in <foreach item="componentKey" index="index" collection="componentKeys" open="(" separator="," close=")">#{componentKey} </foreach> + and root.project_id=p.id + and root.islast=true + and (s.id=root.id or (s.root_snapshot_id=root.id and + <if test="_databaseId != 'mssql'"> + s.path LIKE root.path || root.id || '.%' + </if> + <if test="_databaseId == 'mssql'"> + s.path LIKE root.path + root.id + '.%' + </if> + )) + and i.resource_id=s.project_id </if> <if test="severity != null"> diff --git a/sonar-core/src/test/java/org/sonar/core/issue/IssueDaoTest.java b/sonar-core/src/test/java/org/sonar/core/issue/IssueDaoTest.java index e89df0be30f..1f82e281262 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/IssueDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/IssueDaoTest.java @@ -28,6 +28,7 @@ import org.sonar.core.persistence.AbstractDaoTestCase; import java.util.Collection; import java.util.Date; +import java.util.List; import static com.google.common.collect.Lists.newArrayList; import static org.fest.assertions.Assertions.assertThat; @@ -146,7 +147,10 @@ public class IssueDaoTest extends AbstractDaoTestCase { setupData("select-with-component-children"); IssueQuery issueQuery = new IssueQuery.Builder().componentKeys("key").build(); - assertThat(dao.select(issueQuery)).hasSize(2); + List<IssueDto> issues = newArrayList(dao.select(issueQuery)); + assertThat(issues).hasSize(2); + assertThat(issues.get(0).getId()).isEqualTo(100); + assertThat(issues.get(1).getId()).isEqualTo(101); } } diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/IssueDaoTest/select-with-component-children.xml b/sonar-core/src/test/resources/org/sonar/core/issue/IssueDaoTest/select-with-component-children.xml index ff0635ad372..8a10dc8568e 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/IssueDaoTest/select-with-component-children.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/IssueDaoTest/select-with-component-children.xml @@ -76,13 +76,22 @@ /> <snapshots - id="400" + id="100" project_id="400" - root_snapshot_id="400" + root_snapshot_id="[null]" + path="" + islast="[false]" + /> + + <snapshots + id="101" + project_id="400" + root_snapshot_id="[null]" path="" islast="[true]" /> + <projects id="401" kee="child" @@ -90,11 +99,12 @@ /> <snapshots - id="401" + id="102" project_id="401" - root_snapshot_id="400" - path="400." + root_snapshot_id="101" + path="101." islast="[true]" /> + </dataset> |