This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git

commit 5fd5de9fb8931548f98888abc2d577a4aea341ad
Author: Mark Struberg <[email protected]>
AuthorDate: Tue Apr 6 22:29:16 2021 +0200

    OPENJPA-2862 select SUM return types fixed
    
    As per spec section 4.8.5 Aggregate Functions in the SELECT
    clause we need to handle a few types in a special way
---
 .../org/apache/openjpa/jdbc/kernel/exps/Sum.java   | 23 +++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git 
a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Sum.java 
b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Sum.java
index 677b808..9a7e00c 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Sum.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Sum.java
@@ -35,13 +35,26 @@ class Sum extends NullableAggregateUnaryOp { // OPENJPA-1794
         super(val);
     }
 
+    /**
+     * As per spec section 4.8.5 Aggregate Functions in the SELECT Clause we
+     * need to handle a few types in a special way.
+     */
     @Override
     protected Class getType(Class c) {
-        Class wrap = Filters.wrap(c);
-        if (wrap == Integer.class
-            || wrap == Short.class
-            || wrap == Byte.class)
-            return long.class;
+        if (c == Integer.class ||
+            c == int.class ||
+            c == Short.class ||
+            c == short.class ||
+            c == Byte.class ||
+            c == byte.class) {
+            return Long.class;
+        }
+        if (c == Float.class ||
+            c == float.class ||
+            c == Double.class ||
+            c == double.class ) {
+            return Double.class;
+        }
         return c;
     }
 

Reply via email to