[ http://issues.datanucleus.org/browse/NUCRDBMS-521?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
KC Berg updated NUCRDBMS-521:
Here is a test to demonstrate the use of a subquery's result, via a variable, in the outer query's result. This test also demonstrates using the same subquery result variable in the order clause.
In my checked out version I placed this test in test.jdo.rdbms/src/test/org/datanucleus/tests/SubQueryResultTest.java
Please let me know if this test is adequate as the test is pretty simplistic but I believe it demonstrates the functionality.
> Support for subquery variables in the result and order
> Key: NUCRDBMS-521
> URL: http://issues.datanucleus.org/browse/NUCRDBMS-521
> Project: DataNucleus Store RDBMS
> Issue Type: Improvement
> Components: Queries
> Affects Versions: 3.0.0.m3
> Reporter: KC Berg
> Priority: Minor
> Attachments: dn-core-query.expression.OrderExpression.patch, dn-store.rdbms-query.store.rdbms.query.QueryToSQLMapper.patch, SubQueryResultTest.java
> I was unable to use the returning variable of a subquery in the result or ordering clauses of a query without getting an error. Attempting to use the variable in either the result or order clause would cause a null pointer in compile process of QueryToSQLMapper.
> After reading through the documentation I didn't see that using a subquery variable in the result or ordering clause is even supported, which is why I'm creating this issue as an improvement.
> I've create two patches one for supporting the use of a subquery variable in the result and the other for using the variable in the ordering. I have no idea if I did these patches the "right way" but they both seem to work great in my environment.
> The result patch was a modification to the org/datanucleus/store/rdbms/query/QueryToSQLMapper.java in the store.rdbms project.
> The ordering patch was a modification to org/datanucleus/query/expression/OrderExpression.java in the core project.
> Again I'm not sure if these will work in all cases but none of the unit tests in the two projects failed if that means anything.
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://issues.datanucleus.org/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira