]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3825 try to fix descending sort of numeric values on SQLServer...
authorSimon Brandhof <simon.brandhof@gmail.com>
Tue, 11 Dec 2012 16:27:07 +0000 (17:27 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Tue, 11 Dec 2012 16:27:07 +0000 (17:27 +0100)
sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterSql.java

index 0da49a1f0f2152ba1c4832ab59449a4e052b59a8..3708bccae4a55463c02a5ffff40aaee4979438f0 100644 (file)
@@ -75,7 +75,7 @@ class MeasureFilterSql {
   }
 
   private void init() {
-    sql.append("SELECT block.id, max(block.rid) AS rid, max(block.rootid) AS rootid, max(sortval) AS sortval1, CASE WHEN sortval IS NULL THEN 1 ELSE 0 END AS sortval2 ");
+    sql.append("SELECT block.id, max(block.rid) AS rid, max(block.rootid) AS rootid, max(sortval) AS sortvalmax, CASE WHEN sortval IS NULL THEN 1 ELSE 0 END AS sortflag ");
     for (int index = 0; index < filter.getMeasureConditions().size(); index++) {
       sql.append(", max(crit_").append(index).append(")");
     }
@@ -88,7 +88,7 @@ class MeasureFilterSql {
       appendConditionBlock(index, condition);
     }
 
-    sql.append(") block GROUP BY block.id, sortval2");
+    sql.append(") block GROUP BY block.id, sortflag");
     if (!filter.getMeasureConditions().isEmpty()) {
       sql.append(" HAVING ");
       for (int index = 0; index < filter.getMeasureConditions().size(); index++) {
@@ -99,7 +99,7 @@ class MeasureFilterSql {
       }
     }
     if (filter.sort().isSortedByDatabase()) {
-      sql.append(" ORDER BY sortval2 ASC, sortval1 ");
+      sql.append(" ORDER BY sortflag ASC, sortvalmax ");
       sql.append(filter.sort().isAsc() ? "ASC " : "DESC ");
     }
   }