|
I agree we should changet the query. The attached patch changes the query to
SELECT department, SUM(salary) FROM org.apache.jdo.tck.pc.company.Employee GROUP BY department HAVING COUNT(department) > 0 ORDER BY department.name ascending However, the test still fails, because the calculated SUM(salary) is 30000.0 and 45000.0 instead of the expected 45000.0 and 58000.0. I figured out that the projected salary for employees emp3 and emp4 is null which leads to the wrong sum value. Please note, in the database the salary is correct and gets correctly returned when selecting the entire employee instance. I also change the negative query to SELECT department, SUM(salary) FROM org.apache.jdo.tck.pc.company.Employee GROUP BY department HAVING firstname This should result in an exception, because 'firstname' is not a boolean expression. Currently, JPOX does not catch this error.
Michael Bouschen made changes - 19/Dec/05 06:22 AM
I don't think the ordering is needed on the first query. Otherwise, looks good.
I checked in the updated patch (revision 358395).
However, the test org.apache.jdo.tck.query.result.Having still fails, because it does not return the expected SUM as described above. I have no idea why a null salary gets returned for two of the employees (which leads to the incorrect SUM value). Ideas? Looked at the SQL being generated ?
Good point Andy! Actually the generated SQL is correct.
I know what the problem is: the JDOQL query is not valid. It accesses a field salary that is declared in a subclass of the candidate class. JPOX should catch this, but this is a different problem and I filed a new JIRA issue for this (see I changed the query to access a field declared in the candidate class.
Michael Bouschen made changes - 03/Jan/06 08:56 PM
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"SELECT department, SUM(salary) FROM org.apache.jdo.tck.pc.company.Employee GROUP BY department HAVING COUNT(department.employees) > 0"
You can't COUNT a collection field like employees. Don't you want to do COUNT(department) instead?