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
This commit is contained in:
Mark Struberg 2021-04-06 22:29:16 +02:00
parent bb5503b147
commit 5fd5de9fb8

View File

@ -35,13 +35,26 @@ class Sum extends NullableAggregateUnaryOp { // OPENJPA-1794
super(val); 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 @Override
protected Class getType(Class c) { protected Class getType(Class c) {
Class wrap = Filters.wrap(c); if (c == Integer.class ||
if (wrap == Integer.class c == int.class ||
|| wrap == Short.class c == Short.class ||
|| wrap == Byte.class) c == short.class ||
return long.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; return c;
} }