From 312fa3ba13f096aa08aca799d13b9335eda059a7 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Tue, 19 Sep 2017 11:28:37 +0200 Subject: [PATCH] SONAR-9616 Correctly delete branches when deleting organization --- .../org/sonar/db/component/ComponentDao.java | 2 ++ .../sonar/db/component/ComponentMapper.xml | 1 + .../sonar/db/component/ComponentDaoTest.java | 30 +++++++++++++++++++ .../organization/ws/DeleteActionTest.java | 14 +++++++++ 4 files changed, 47 insertions(+) diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java index b8df226eb4e..e3b3b556c6b 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java @@ -249,6 +249,8 @@ public class ComponentDao implements Dao { /** * Select all root components (projects and views), including disabled ones, for a given organization. + * + * Branches are not returned */ public List selectAllRootsByOrganization(DbSession dbSession, String organizationUuid) { return mapper(dbSession).selectAllRootsByOrganization(organizationUuid); diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml index dec681a80fd..feaa6661866 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml @@ -243,6 +243,7 @@ p.scope='PRJ' and (p.qualifier='TRK' or p.qualifier='VW' or p.qualifier='APP') and p.organization_uuid = #{organizationUuid,jdbcType=VARCHAR} + and p.main_branch_project_uuid IS NULL