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
1 changed files with 18 additions and 5 deletions

View File

@ -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;
}