]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10587 Don't return external issues in batch/issues
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Mon, 11 Jun 2018 15:32:21 +0000 (17:32 +0200)
committerSonarTech <sonartech@sonarsource.com>
Tue, 12 Jun 2018 18:20:57 +0000 (20:20 +0200)
server/sonar-db-dao/src/main/resources/org/sonar/db/issue/IssueMapper.xml
server/sonar-server/src/test/java/org/sonar/server/batch/IssuesActionTest.java

index d541fade3cad4134448483d8f5165c016be25e41..122f92b49447db84b100765ac1386bc84fda749f 100644 (file)
     inner join projects p on p.uuid=i.component_uuid
     inner join projects root on root.uuid=i.project_uuid
     where
-    r.is_external = ${_false} and
+    (r.is_external is NULL or r.is_external = ${_false}) and
     i.component_uuid = #{componentUuid,jdbcType=VARCHAR} and
     i.status &lt;&gt; 'CLOSED'
   </select>
     inner join projects p on p.uuid = i.component_uuid
     inner join projects root on root.uuid = i.project_uuid
     where
-    r.is_external = ${_false} and
+    (r.is_external is NULL or r.is_external = ${_false}) and
     i.project_uuid = #{projectUuid, jdbcType=VARCHAR} and
     p.module_uuid_path like  #{likeModuleUuidPath, jdbcType=VARCHAR} escape '/' and
     i.status &lt;&gt; 'CLOSED'
index fc85bda10e2c5bf02294a82a56208f1036b62e39..195086c3d3b9bd55a9da81f61f0e6e384b0f7b13 100644 (file)
@@ -173,6 +173,10 @@ public class IssuesActionTest {
 
     RuleDefinitionDto external = db.rules().insert(ruleDefinitionDto -> ruleDefinitionDto.setIsExternal(true));
     IssueDto issueFromExteralruleOnFile = db.issues().insert(external, project, file, i -> i.setKee("ON_FILE_FROM_EXTERNAL"));
+    
+    RuleDefinitionDto migrated = db.rules().insert();
+    db.executeUpdateSql("update rules set is_external = NULL where rules.id = ?", migrated.getId());
+    IssueDto issueFromMigratedRule = db.issues().insert(migrated, project, file, i -> i.setKee("MIGRATED"));
 
     addPermissionTo(project);
     try (CloseableIterator<ServerIssue> result = callStream(project.getKey(), null)) {
@@ -181,7 +185,8 @@ public class IssuesActionTest {
         .containsExactlyInAnyOrder(
           tuple(issueOnFile.getKey(), module.getKey()),
           tuple(issueOnModule.getKey(), module.getKey()),
-          tuple(issueOnProject.getKey(), project.getKey()));
+          tuple(issueOnProject.getKey(), project.getKey()),
+          tuple(issueFromMigratedRule.getKey(), module.getKey()));
     }
   }