]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3825 another try to fix compatibility with SQLServer and Oracle
authorSimon Brandhof <simon.brandhof@gmail.com>
Tue, 11 Dec 2012 17:50:57 +0000 (18:50 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Tue, 11 Dec 2012 17:50:57 +0000 (18:50 +0100)
sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterSql.java

index 3708bccae4a55463c02a5ffff40aaee4979438f0..f332a2f0d8318e3aa3f6aa3a6fcc8ba7d931c52a 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 sortvalmax, CASE WHEN sortval IS NULL THEN 1 ELSE 0 END AS sortflag ");
+    sql.append("SELECT block.id, max(block.rid) AS rid, max(block.rootid) AS rootid, max(sortval) AS sortmax, CASE WHEN max(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, sortflag");
+    sql.append(") block GROUP BY block.id ");
     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 sortflag ASC, sortvalmax ");
+      sql.append(" ORDER BY sortflag ASC, sortmax ");
       sql.append(filter.sort().isAsc() ? "ASC " : "DESC ");
     }
   }