DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Key: NUCCORE-516
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Andy Jefferson
Reporter: Andy Jefferson
Votes: 0
Watchers: 0

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

Generic compilation of JDOQL subquery via API can omit the rename of candidate in some cases

Created: 27/Apr/10 11:16 AM   Updated: 24/May/10 03:44 PM   Resolved: 27/Apr/10 12:11 PM
Component/s: Queries
Affects Version/s: 2.1.0.m1, 2.1.0.m2
Fix Version/s: 2.1.0.m3

 Description  « Hide
If we have
Query sub = pm.newQuery(Employee.class);
sub.setFilter("this.manager == :manager");
Query apiQuery = pm.newQuery(Employee.class);
apiQuery.setFilter("this.weeklyhours> averageWeeklyhours");
apiQuery.addSubquery(sub, "double averageWeeklyhours", "this.department.employees", "this.manager");

this equates to

SELECT FROM " + Employee.class.getName() + " WHERE this.weeklyhours > " +
    "(SELECT AVG(e.weeklyhours) FROM this.department.employees e " +
    " WHERE e.manager == this.manager)

but when specified via the API is being generically compiled as

  [filter:DyadicExpression{PrimaryExpression{this.weeklyhours} > VariableExpression{averageWeeklyhours}}]
  [symbols: averageWeeklyhours type=unknown, this]
  [subquery: averageWeeklyhours
    [from:ClassExpression(candidate=this.department.employees alias=this)]
    [filter:DyadicExpression{PrimaryExpression{this.manager} = PrimaryExpression{this.manager}}]
    [symbols: this]]

i.e the rename of the subquery candidate hasn't happened (likely because the subquery candidate is an expression)

Andy Jefferson added a comment - 27/Apr/10 12:11 PM
SVN trunk now compiles the specified query to be

  [filter:DyadicExpression{PrimaryExpression{this.weeklyhours} > VariableExpression{averageWeeklyhours}}]
  [symbols: averageWeeklyhours type=unknown, this]
  [subquery: averageWeeklyhours
    [from:ClassExpression(candidate=this.department.employees alias=sub_this)]
    [filter:DyadicExpression{PrimaryExpression{sub_this.manager} = PrimaryExpression{this.manager}}]
    [symbols: sub_this]]

Andy Jefferson made changes - 27/Apr/10 12:11 PM
Field Original Value New Value
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 2.1.0.m3 [ 10942 ]
Resolution Fixed [ 1 ]
Andy Jefferson made changes - 24/May/10 03:44 PM
Status Resolved [ 5 ] Closed [ 6 ]