← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20379: Program indicator, ZeroPositiveValueCountFunction, cast

 

------------------------------------------------------------
revno: 20379
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2015-09-27 22:01:16 +0200
message:
  Program indicator, ZeroPositiveValueCountFunction, cast
modified:
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java
  dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/sqlfunc/ZeroPositiveValueCountFunction.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java	2015-09-27 09:29:50 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java	2015-09-27 20:01:16 +0000
@@ -527,10 +527,10 @@
     public void testGetAnalyticsSqlWithFunctionsZpvc()
     {
         String expected = 
-            "nullif((" +
+            "nullif(cast((" +
             "case when \"EZq9VbPWgML\" >= 0 then 1 else 0 end + " +
             "case when \"GCyeKSqlpdk\" >= 0 then 1 else 0 end" +
-            "),0)";
+            ") as double precision),0)";
         
         String expression = "d2:zpvc(#{OXXcwl6aPCQ.EZq9VbPWgML},#{OXXcwl6aPCQ.GCyeKSqlpdk})";
         

=== modified file 'dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/sqlfunc/ZeroPositiveValueCountFunction.java'
--- dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/sqlfunc/ZeroPositiveValueCountFunction.java	2015-09-24 21:35:11 +0000
+++ dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/sqlfunc/ZeroPositiveValueCountFunction.java	2015-09-27 20:01:16 +0000
@@ -49,13 +49,13 @@
             throw new IllegalArgumentException( "Illegal arguments, expected at least one argument" );
         }
         
-        String sql = "nullif((";
+        String sql = "nullif(cast((";
         
         for ( String value : args )
         {
             sql += "case when " + value + " >= 0 then 1 else 0 end + ";
         }
         
-        return TextUtils.removeLast( sql, "+" ).trim() + "),0)";
+        return TextUtils.removeLast( sql, "+" ).trim() + ") as double precision),0)";
     }
 }