JDOQL Subquery failing


ebenzacar@...
 
Edited

I'm trying to get a complex query working with a subquery in the filter which is failing in the JDOQL Parser.  I have diluted it to a very simple use case with a subselect which is failing as well.  Please see the test-case on github.
I am fairly sure there is something which does not match expected syntax, but I am trying to follow the examples in the DN Docs, but the parser is still failing. 

My query is:

            Query q = pm.newQuery(Person.class);
q.setFilter("id == (select count(id) from Person p) "); // fails
List<Person> results = q.executeList();

and the exception I get is the following:

2021-07-23 15:31:44 INFO  JDO:92 - Exception thrown
expected ')' at character 15 in "id == (select id from Person p)"
org.datanucleus.store.query.QueryCompilerSyntaxException: expected ')' at character 15 in "id == (select id from Person p)"
at org.datanucleus.query.compiler.JDOQLParser.processPrimary(JDOQLParser.java:780)
at org.datanucleus.query.compiler.JDOQLParser.processUnaryExpression(JDOQLParser.java:643)
at org.datanucleus.query.compiler.JDOQLParser.processMultiplicativeExpression(JDOQLParser.java:569)
at org.datanucleus.query.compiler.JDOQLParser.processAdditiveExpression(JDOQLParser.java:540)
at org.datanucleus.query.compiler.JDOQLParser.processRelationalExpression(JDOQLParser.java:460)
at org.datanucleus.query.compiler.JDOQLParser.processAndExpression(JDOQLParser.java:437)
at org.datanucleus.query.compiler.JDOQLParser.processExclusiveOrExpression(JDOQLParser.java:423)
at org.datanucleus.query.compiler.JDOQLParser.processInclusiveOrExpression(JDOQLParser.java:409)
at org.datanucleus.query.compiler.JDOQLParser.processConditionalAndExpression(JDOQLParser.java:395)
at org.datanucleus.query.compiler.JDOQLParser.processConditionalOrExpression(JDOQLParser.java:376)
at org.datanucleus.query.compiler.JDOQLParser.processExpression(JDOQLParser.java:365)
at org.datanucleus.query.compiler.JDOQLParser.parse(JDOQLParser.java:88)
at org.datanucleus.query.compiler.JavaQueryCompiler.compileFilter(JavaQueryCompiler.java:600)
at org.datanucleus.query.compiler.JDOQLCompiler.compile(JDOQLCompiler.java:103)
at org.datanucleus.store.query.AbstractJDOQLQuery.compileGeneric(AbstractJDOQLQuery.java:392)
at org.datanucleus.store.query.AbstractJDOQLQuery.compileInternal(AbstractJDOQLQuery.java:450)
at org.datanucleus.store.rdbms.query.JDOQLQuery.compileInternal(JDOQLQuery.java:263)
at org.datanucleus.store.query.Query.executeQuery(Query.java:1936)
at org.datanucleus.store.query.Query.executeWithArray(Query.java:1864)
at org.datanucleus.store.query.Query.execute(Query.java:1846)
at org.datanucleus.api.jdo.JDOQuery.executeInternal(JDOQuery.java:439)
at org.datanucleus.api.jdo.JDOQuery.executeList(JDOQuery.java:345)
 




Does anyone have any ideas what I have done wrong with my subselect?  I've tried tracing through the `JDOQLParser` but without much success.

Thanks,

Eric

Join main@datanucleus.groups.io to automatically receive all group messages.