Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDOQL : Support compilation of ":param.collField.contains()" for (implicit) named parameters #32

Open
andyjefferson opened this issue Apr 11, 2016 · 0 comments

Comments

@andyjefferson
Copy link
Member

If we want to do something like

SELECT FROM MyClass WHERE :myObj.someField.contains(this.field)

and then try to compile it, we get a message like

org.datanucleus.store.rdbms.sql.expression.IllegalExpressionOperationException: Cannot perform operation ".contains" on org.datanucleus.store.rdbms.sql.expression.NullLiteral@2ea41516
at org.datanucleus.store.rdbms.sql.expression.SQLExpression.invoke(SQLExpression.java:601)
at org.datanucleus.store.rdbms.query.QueryToSQLMapper.processInvokeExpression(QueryToSQLMapper.java:3585)
at org.datanucleus.query.evaluator.AbstractExpressionEvaluator.compilePrimaryExpression(AbstractExpressionEvaluator.java:213)
at org.datanucleus.query.evaluator.AbstractExpressionEvaluator.compileUnaryExpression(AbstractExpressionEvaluator.java:182)
at org.datanucleus.query.evaluator.AbstractExpressionEvaluator.compileAdditiveMultiplicativeExpression(AbstractExpressionEvaluator.java:161)
at org.datanucleus.query.evaluator.AbstractExpressionEvaluator.compileRelationalExpression(AbstractExpressionEvaluator.java:136)
at org.datanucleus.query.evaluator.AbstractExpressionEvaluator.compileOrAndExpression(AbstractExpressionEvaluator.java:78)
at org.datanucleus.query.evaluator.AbstractExpressionEvaluator.evaluate(AbstractExpressionEvaluator.java:46)
at org.datanucleus.query.expression.Expression.evaluate(Expression.java:338)
at org.datanucleus.store.rdbms.query.QueryToSQLMapper.compileFilter(QueryToSQLMapper.java:495)
at org.datanucleus.store.rdbms.query.QueryToSQLMapper.compile(QueryToSQLMapper.java:416)
at org.datanucleus.store.rdbms.query.JDOQLQuery.compileQueryFull(JDOQLQuery.java:918)
at org.datanucleus.store.rdbms.query.JDOQLQuery.compileInternal(JDOQLQuery.java:344)
at org.datanucleus.store.query.Query.compile(Query.java:1669)

This is because the parameter doesn't have a value at the point of compilation, hence you have the equivalent of an NPE but in a query. Need a better way of handling this

@andyjefferson andyjefferson changed the title Handle compilation of ":param.collField.contains()" for (implicit) named parameters JDOQL : Support compilation of ":param.collField.contains()" for (implicit) named parameters Sep 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant