Issue Details (XML | Word | Printable)

Key: NUCCORE-1033
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Azuo Lee
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
DataNucleus Core

JDOQL: DyadicExpression can not be specified in SELECT/ORDER clause even if it is in GROUP clause

Created: 22/Apr/13 11:55 AM   Updated: 15/May/13 09:31 AM   Resolved: 22/Apr/13 07:41 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 3.2.3

File Attachments: 1. Zip Archive grouping-dyadic-expression.zip (3 kB)



 Description  « Hide
Following JDOQL,

select this.birthDate.getYear() / 10, count(this)
from Person
group by this.birthDate.getYear() / 10
order by this.birthDate.getYear() / 10 desc

which DOES conform to JDO spec 14.6.10, will raise an NucleusUserException:
JDOQL query has result clause DyadicExpression{InvokeExpression{[PrimaryExpression{this.birthDate}].getYear(<none>)} / Literal{10}} but this is invalid (see JDO spec 14.6.10). When specified with grouping should be aggregate, or grouping expression


Andy Jefferson added a comment - 22/Apr/13 12:01 PM
No testcase

Andy Jefferson made changes - 22/Apr/13 12:01 PM
Field Original Value New Value
Priority Major [ 3 ] Incomplete [ 6 ]
Azuo Lee added a comment - 22/Apr/13 12:03 PM
Exception stack trace:

org.datanucleus.exceptions.NucleusUserException: JDOQL query has result clause DyadicExpression{InvokeExpression{[PrimaryExpression{this.birthDate}].getYear(<none>)} / Literal{10}} but this is invalid (see JDO spec 14.6.10). When specified with grouping should be aggregate, or grouping expression
at org.datanucleus.query.compiler.JDOQLCompiler.compile(JDOQLCompiler.java:121)
at org.datanucleus.store.query.AbstractJDOQLQuery.compileInternal(AbstractJDOQLQuery.java:343)
at org.datanucleus.store.rdbms.query.JDOQLQuery.compileInternal(JDOQLQuery.java:211)
at org.datanucleus.store.query.Query.executeQuery(Query.java:1743)
at org.datanucleus.store.query.Query.executeWithMap(Query.java:1689)
at org.datanucleus.api.jdo.JDOQuery.executeWithMap(JDOQuery.java:334)

Azuo Lee added a comment - 22/Apr/13 12:09 PM
Sorry, I don't know how to create a test case... but I can confirm the exception is thrown because
JDOQLCompiler.isExpressionGroupingOrAggregate method won't handle DyadicExpression at all, it just simply returns false for a DyadicExpression.

Andy Jefferson added a comment - 22/Apr/13 12:16 PM
The front page of JIRA gives a link to what a testcase is and that one is required for EVERY ISSUE. http://www.datanucleus.org/project/problem_reporting.html

Azuo Lee added a comment - 22/Apr/13 02:02 PM - edited
It takes me several hours to make a test case... anyway, the testcase is attached now.

When making the testcase, I found a new bug (also included in the testcase):

following JDOQL (which also conforms to JDO spec),

select h.owner, h.address
from org.datanucleus.test.Person
where this.houses.contains(h)
order by h.id asc

can not be executed (NullPointerException thrown), unless the ordering clause is not specified.

Azuo Lee made changes - 22/Apr/13 02:02 PM
Attachment grouping-dyadic-expression.zip [ 11944 ]
Andy Jefferson added a comment - 22/Apr/13 02:46 PM
If you have some other "issue" please raise that in a separate JIRA issue, with its own testcase; a JIRA issue is not a bucket for dumping lots of things together into.

Also suggest you debug this further and attach a patch to this issue, for SVN project "core", since its seemingly of importance for your project

Andy Jefferson made changes - 22/Apr/13 02:46 PM
Priority Incomplete [ 6 ] Major [ 3 ]
Andy Jefferson made changes - 22/Apr/13 07:40 PM
Project DataNucleus AccessPlatform [ 10140 ] DataNucleus Core [ 10143 ]
Key NUCACCESS-115 NUCCORE-1033
Andy Jefferson added a comment - 22/Apr/13 07:41 PM
SVN trunk now adds a simple toString() comparison of the result expression with grouping expression(s) for any other types not explicitly defined.

Andy Jefferson made changes - 22/Apr/13 07:41 PM
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 3.2.3 [ 11924 ]
Resolution Fixed [ 1 ]
Andy Jefferson made changes - 15/May/13 09:31 AM
Status Resolved [ 5 ] Closed [ 6 ]