]> source.dussan.org Git - sonarqube.git/commitdiff
Fix SnapshotDao#selectSnapshotsByQuery() when using component UUID and sorting
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Sat, 30 Apr 2016 08:45:25 +0000 (10:45 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Sat, 30 Apr 2016 08:45:25 +0000 (10:45 +0200)
sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml
sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java

index 8be7709f2748c652017c2664c03702c0345694c7..1cc4b2aff962ec0048349b71caba94a878c9bd2c 100644 (file)
     <if test="query.sortField != null">
       ORDER BY
       <if test="query.sortField == 'created_at'">
-        created_at
+        s.created_at
       </if>
       <if test="query.sortOrder == 'asc'">
         asc
index 4fdd5c749bdd0c73da5f23c785e60175af2f68cd..76fe88ddf0098cb01f20f8532c006bee16795005 100644 (file)
@@ -173,6 +173,9 @@ public class SnapshotDaoTest {
     assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setSort(BY_DATE, ASC)).get(0).getId()).isEqualTo(1L);
     assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setSort(BY_DATE, DESC)).get(0).getId()).isEqualTo(3L);
 
+    assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentUuid("ABCD").setSort(BY_DATE, ASC)).get(0).getId()).isEqualTo(1L);
+    assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentUuid("ABCD").setSort(BY_DATE, DESC)).get(0).getId()).isEqualTo(3L);
+
     assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setScope(Scopes.PROJECT).setQualifier(Qualifiers.PACKAGE))).extracting("id").containsOnly(1L);
     assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setScope(Scopes.DIRECTORY).setQualifier(Qualifiers.PACKAGE))).extracting("id").containsOnly(
       2L, 3L, 4L, 5L, 6L);