Issue Details (XML | Word | Printable)

Key: NUCRDBMS-792
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Ivan Badia
Votes: 1
Watchers: 1
Operations

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

Map.containsKey generates invalid query

Created: 25/Apr/14 09:27 AM   Updated: 04/Nov/14 08:31 AM   Resolved: 03/Nov/14 05:04 PM
Component/s: Queries
Affects Version/s: 3.2.12
Fix Version/s: 4.0.5

File Attachments: 1. Zip Archive NUCRDBMS-792.zip (479 kB)


Datastore: Microsoft SQL Server
Severity: Development


 Description  « Hide
When we use the JDOQL method containsKey over a Map parameter, the sql generated is invalid. The condition is added outside the EXISTS() function

In the testcase attached the SQL query generated is:

SELECT DISTINCT 'mydomain.model.PersonGroup' AS NUCLEUS_TYPE
,A0.ID
,A0."NAME"
FROM PERSONGROUP A0
LEFT OUTER JOIN FAMILY B0 ON A0.FAMILY_ID_OID = B0.ID
WHERE (B0.ID IN (1))
AND EXISTS (
SELECT 1
FROM PERSONGROUPCARRELATION A0_SUB
INNER JOIN PERSON B0_SUB ON A0_SUB.PERSON_ID_OID = B0_SUB.ID
WHERE A0_SUB.RELATION_ID_OWN = A0.ID
)
AND (
(
1 = B0_SUB.ID
OR 2 = B0_SUB.ID
)
)

When the expected query would be:


SELECT DISTINCT 'mydomain.model.PersonGroup' AS NUCLEUS_TYPE
,A0.ID
,A0."NAME"
FROM PERSONGROUP A0
LEFT OUTER JOIN FAMILY B0 ON A0.FAMILY_ID_OID = B0.ID
WHERE (B0.ID IN (1))
AND EXISTS (
SELECT 1
FROM PERSONGROUPCARRELATION A0_SUB
INNER JOIN PERSON B0_SUB ON A0_SUB.PERSON_ID_OID = B0_SUB.ID
WHERE A0_SUB.RELATION_ID_OWN = A0.ID
AND B0_SUB.ID IN (
1
,2
)
)


If you require additional information, please, let me know.


Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 03/Nov/14 05:04 PM
GitHub master adds support for the special case of IN syntax with literal containers for Map key, Map value and Array element containment.

No idea why others couldn't provide this since was a simple copy-paste from CollectionContainsMethod (the one that the O/P created a test for, for comparison purposes saying it worked ok); maybe it would be simpler just to not have the project as open source?