aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao/src/main/resources
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2019-09-17 15:05:44 -0500
committerSonarTech <sonartech@sonarsource.com>2019-09-24 20:21:17 +0200
commitd59c35feefa448be40219b605b6c3672aad0201a (patch)
tree1307de9b1774b09573cedb36bf3bcc217bc39780 /server/sonar-db-dao/src/main/resources
parent10fa91188ba2e8fdfaac8ecdbdca483a2f96d1a3 (diff)
downloadsonarqube-d59c35feefa448be40219b605b6c3672aad0201a.tar.gz
sonarqube-d59c35feefa448be40219b605b6c3672aad0201a.zip
SONAR-12390 Prevent analysis deletion when it is a baseline
Diffstat (limited to 'server/sonar-db-dao/src/main/resources')
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml23
1 files changed, 8 insertions, 15 deletions
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml
index 38b34f43afe..1151abc69e5 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml
@@ -22,26 +22,19 @@
</if>
</select>
- <select id="selectPurgeableAnalysesWithEvents" parameterType="String" resultType="PurgeableAnalysis">
+ <select id="selectPurgeableAnalyses" parameterType="String" resultType="PurgeableAnalysis">
select
- s.id as "analysisId", s.uuid as "analysisUuid", s.created_at as "date", ${_true} as "hasEvents", islast as "isLast", ve.name as "version"
+ s.id as "analysisId",
+ s.uuid as "analysisUuid",
+ s.created_at as "date",
+ case when ve.analysis_uuid is not null then ${_true} else ${_false} end as "hasEvents",
+ islast as "isLast",
+ case when ve.category='Version' then ve.name else null end as "version"
from snapshots s
- left outer join events ve on ve.analysis_uuid=s.uuid and ve.category='Version'
- left outer join new_code_periods npc on ve.analysis_uuid=s.uuid and ve.category='Version'
+ left outer join events ve on ve.analysis_uuid=s.uuid
where
s.component_uuid=#{componentUuid,jdbcType=VARCHAR}
and s.status='P'
- and exists(select e.id from events e where e.analysis_uuid=s.uuid)
- </select>
-
- <select id="selectPurgeableAnalysesWithoutEvents" parameterType="String" resultType="PurgeableAnalysis">
- select
- s.id as "analysisId", s.uuid as "analysisUuid", s.created_at as "date", ${_false} as "hasEvents", islast as "isLast", NULL as "version"
- from snapshots s
- where
- s.component_uuid=#{componentUuid,jdbcType=VARCHAR}
- and s.status='P'
- and not exists(select e.id from events e where e.analysis_uuid=s.uuid)
</select>
<select id="selectSpecificAnalysisNewCodePeriod" parameterType="String" resultType="String">