]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2473 Fix SQL request to prevent "closing" again a review
authorFabrice Bellingard <bellingard@gmail.com>
Wed, 25 May 2011 09:17:47 +0000 (11:17 +0200)
committerFabrice Bellingard <bellingard@gmail.com>
Wed, 25 May 2011 09:17:47 +0000 (11:17 +0200)
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java
plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest/fixture.xml
plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest/shouldCloseReviewWithoutCorrespondingViolation-result.xml

index 0b32e50b288845001d7ac87b2215b763ed860393..49ee853d902d4c5412126e656c3083cba0f73f2a 100644 (file)
@@ -75,7 +75,7 @@ public class CloseReviewsDecorator implements Decorator {
   }
 
   protected String generateUpdateOnResourceSqlRequest(int resourceId, int snapshotId) {
-    return "UPDATE reviews SET status='CLOSED', updated_at=CURRENT_TIMESTAMP WHERE resource_id = " + resourceId
+    return "UPDATE reviews SET status='CLOSED', updated_at=CURRENT_TIMESTAMP WHERE status='OPEN' AND resource_id = " + resourceId
         + " AND rule_failure_permanent_id NOT IN " + "(SELECT permanent_id FROM rule_failures WHERE snapshot_id = " + snapshotId
         + " AND permanent_id IS NOT NULL)";
   }
index 6142cbf4f3bd15a407451a638f3349d76ba67732..2f432d7f74578a4f7a7703e8a748fa0dd5d74674 100644 (file)
                        status="OPEN"
                        rule_failure_permanent_id="3"
                        resource_id="666"/>
+  <reviews
+                       id="4"
+                       status="CLOSED"
+                       rule_failure_permanent_id="2"
+                       resource_id="666"/>
 
 </dataset>
\ No newline at end of file
index db7bf76f0e01a23967d9f22cc4611c0232778379..49123b1a1a95f22ae8c00dd1087ce9fa6cc792a1 100644 (file)
                        rule_failure_permanent_id="3"
                        resource_id="666"
                        created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" review_type="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
+  <reviews
+                       id="4"
+                       status="CLOSED"
+                       rule_failure_permanent_id="2"
+                       resource_id="666"
+                       created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" review_type="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
 
 </dataset>
\ No newline at end of file