]> source.dussan.org Git - sonarqube.git/commitdiff
fix issue_changes insert with correct jdbcType and fix issue change migration
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Tue, 13 Jan 2015 08:53:29 +0000 (09:53 +0100)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Tue, 13 Jan 2015 08:53:29 +0000 (09:53 +0100)
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/FeedIssueChangesLongDates.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/FeedIssueChangesLongDatesTest.java
sonar-core/src/main/resources/org/sonar/core/issue/db/IssueChangeMapper.xml

index 2db5dc0ea39d252bf1aef12faa1d428a8df9d941..dcd1feac4938baeff971434b72b75e2b3efba741 100644 (file)
@@ -44,7 +44,7 @@ public class FeedIssueChangesLongDates extends BaseDataChange {
     final long now = system.now();
 
     MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.select("SELECT i.created_at, i.updated_at, i.issue_change_creation_date_ms, i.id FROM issue_changes i WHERE created_at_ms IS NULL");
+    massUpdate.select("SELECT i.created_at, i.updated_at, i.issue_change_creation_date, i.id FROM issue_changes i WHERE created_at_ms IS NULL");
     massUpdate.update("UPDATE issue_changes SET created_at_ms=?, updated_at_ms=?, issue_change_creation_date_ms=? WHERE id=?");
     massUpdate.rowPluralName("issue_changes");
     massUpdate.execute(new MassUpdate.Handler() {
index 5cd281bca35de7ac5764bc2d76bbcd712cb2b6f6..ecc00bb81ba5b2a43b6679c165723bd303f6cce8 100644 (file)
@@ -48,6 +48,6 @@ public class FeedIssueChangesLongDatesTest {
 
     int countWithAllDateFieldsNull = db
       .countSql("select count(*) from issue_changes where created_at_ms is not null and updated_at_ms is not null and issue_change_creation_date_ms is not null");
-    assertThat(countWithAllDateFieldsNull).isEqualTo(1);
+    assertThat(countWithAllDateFieldsNull).isEqualTo(2);
   }
 }
index c4fb6ca2df46676085674984709ff2839168009c..c1cfc09fb36ccde279235c49dd04919491c22063 100644 (file)
     c.issue_change_creation_date as issueChangeCreationDate
   </sql>
 
-  <insert id="insert" parameterType="IssueChange" useGeneratedKeys="false" keyProperty="id" >
-    INSERT INTO issue_changes (kee, issue_key, user_login, change_type, change_data, created_at, updated_at, issue_change_creation_date)
-    VALUES (#{kee,jdbcType=VARCHAR}, #{issueKey,jdbcType=VARCHAR}, #{userLogin,jdbcType=VARCHAR}, #{changeType,jdbcType=VARCHAR}, #{changeData,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{issueChangeCreationDate,jdbcType=TIMESTAMP})
+  <insert id="insert" parameterType="IssueChange" useGeneratedKeys="false" keyProperty="id">
+    INSERT INTO issue_changes (kee, issue_key, user_login, change_type, change_data, created_at, updated_at,
+    issue_change_creation_date)
+    VALUES (#{kee,jdbcType=VARCHAR}, #{issueKey,jdbcType=VARCHAR}, #{userLogin,jdbcType=VARCHAR},
+    #{changeType,jdbcType=VARCHAR}, #{changeData,jdbcType=VARCHAR}, #{createdAt,jdbcType=BIGINT},
+    #{updatedAt,jdbcType=BIGINT}, #{issueChangeCreationDate,jdbcType=BIGINT})
   </insert>
 
-  <delete id="delete" parameterType="string" >
+  <delete id="delete" parameterType="string">
     delete from issue_changes where kee=#{id}
   </delete>
 
-  <update id="update" parameterType="map" >
+  <update id="update" parameterType="map">
     update issue_changes set change_data=#{changeData}, updated_at=#{updatedAt} where kee=#{kee}
   </update>
 
@@ -45,7 +48,8 @@
     <include refid="issueChangeColumns"/>
     from issue_changes c
     inner join issues i on i.kee = c.issue_key
-    inner join (select p.id,p.kee from projects p where (p.root_id=#{componentId} and p.qualifier &lt;&gt; 'BRC') or (p.id=#{componentId})) p on p.id=i.component_id
+    inner join (select p.id,p.kee from projects p where (p.root_id=#{componentId} and p.qualifier &lt;&gt; 'BRC') or
+    (p.id=#{componentId})) p on p.id=i.component_id
     <where>
       and c.change_type=#{changeType}
       and i.status &lt;&gt; 'CLOSED'