solomax commented on code in PR #244:
URL: https://github.com/apache/openjpa/pull/244#discussion_r4407816041
##########
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Math.java:
##########
@@ -144,7 +144,29 @@ private SQLBuffer newSQLBuffer(Select sel, ExpContext ctx,
ExpState state) {
public Object load(ExpContext ctx, ExpState state, Result res)
throws SQLException {
return Filters.convert(res.getObject(this, JavaSQLTypes.JDBC_DEFAULT,
- null), getType());
+ null), getType(ctx));
+ }
+
+ /**
+ * Return the type of the result. An operand without a known type, such
+ * as an input parameter, takes the type of the value bound to it.
+ */
+ private Class getType(ExpContext ctx) {
+ if (_cast != null) {
+ return _cast;
+ }
+ return Filters.promote(operandType(_val1, ctx), operandType(_val2,
ctx));
+ }
+
+ private static Class operandType(Val val, ExpContext ctx) {
+ Class type = val.getType();
+ if (type == Object.class && val instanceof Param && ctx.params !=
null) {
Review Comment:
```suggestion
if (type == Object.class && val instanceof Param valP && ctx.params
!= null) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]