Boolean properties not correctly mapped in certain queries
Project: DataNucleus Store RDBMS
Issue Type: Bug
Affects Versions: 3.0.1
Reporter: Daniel Baldes
The attached test case contains a class (B) with a boolean property which is mapped to a TINYINT column.
It runs two JDOQL queries. In the first one, the "boolProperty" condition is correctly mapped to the SQL where-clause "BOOLPROP = 1"; in the second one, the condition is incorrectly mapped to just "BOOLPROP".
(Note that this seems to work with HSQLDB as used in the test case, but not with Oracle and likely some other RDBMS; the testcase shall just demonstrate query generation)
"elements.contains(anElement) && anElement.booleanProperty && anElement.c.bs.isEmpty()"
SELECT DISTINCT 'org.datanucleus.test.A' AS NUCLEUS_TYPE,A0.A_ID FROM A A0 INNER JOIN B B0 ON A0.A_ID = B0.ELEMENTS_A_ID_OID LEFT OUTER JOIN "C" C0 ON B0.C_C_ID_OID = C0.C_ID WHERE B0.BOOLPROP = 1 AND ((SELECT COUNT(*) FROM B A0_SUB WHERE A0_SUB.C_C_ID_OID = C0.C_ID) = 0)
"elements.contains(anElement) && anElement.booleanProperty && !anElement.c.bs.isEmpty()"
SELECT 'org.datanucleus.test.A' AS NUCLEUS_TYPE,A0.A_ID FROM A A0 WHERE EXISTS (SELECT 1 FROM B A0_SUB LEFT OUTER JOIN "C" B0_SUB ON A0_SUB.C_C_ID_OID = B0_SUB.C_ID WHERE A0_SUB.ELEMENTS_A_ID_OID = A0.A_ID AND A0_SUB.BOOLPROP AND NOT ((SELECT COUNT(*) FROM B A0_SUB_SUB WHERE A0_SUB_SUB.C_C_ID_OID = B0_SUB.C_ID) = 0))
The latter SQL query leads to an "ORA-00920: invalid relational operator" with oracle.
(I'm aware that these queries do not make sense, they are just the easiest way to show the problem which arises in some real world queries in my software).
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