]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8595 make ComponentMapper.selectByQuery return org key
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 12 Jan 2017 10:36:06 +0000 (11:36 +0100)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 16 Jan 2017 10:38:43 +0000 (11:38 +0100)
sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml
sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java

index 2d9c0ddab68c228d790f04fed1e25974b9aeb335..bb0d24b393e32cde2f89aaacb575f374cc742a70 100644 (file)
 
   <select id="selectByQuery" resultType="Component">
     select
-    <include refid="componentColumns"/>
+      <include refid="componentColumns"/>,
+      o.kee as organizationKey
     <include refid="sqlSelectByQuery"/>
     ORDER BY LOWER(p.name), p.name, p.id
   </select>
 
   <sql id="sqlSelectByQuery">
     from projects p
-    <where>
-      AND p.enabled=${_true}
+    inner join organizations o on
+      o.uuid = p.organization_uuid
+    where
+      p.enabled=${_true}
       AND p.copy_component_uuid is null
       <if test="query.qualifiers!=null">
       AND p.qualifier in
           )
         )
       </if>
-    </where>
   </sql>
 
   <!-- "p" is ancestors -->
index 2038172b9c2bf7aff2add708e88a8b90889a2884..a82695097b42b6b28faa5ea70dd0ee9666682627 100644 (file)
@@ -782,7 +782,9 @@ public class ComponentDaoTest {
 
     assertThat(result).hasSize(3);
     assertThat(count).isEqualTo(9);
-    assertThat(result).extracting("name").containsExactly("project-2", "project-3", "project-4");
+    assertThat(result).extracting(ComponentDto::name).containsExactly("project-2", "project-3", "project-4");
+    assertThat(result).extracting(ComponentDto::getOrganizationUuid).containsOnly(organizationDto.getUuid());
+    assertThat(result).extracting(ComponentDto::getOrganizationKey).containsOnly(organizationDto.getKey());
   }
 
   @Test