Issue Details (XML | Word | Printable)

Key: NUCRDBMS-423
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Andy Jefferson
Reporter: Areg Beketovski
Votes: 0
Watchers: 0
Operations

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

Collection.contains() in JDOQL does not verify items type against argument, only id is compared

Created: 24/Jun/10 03:15 PM   Updated: 13/Nov/10 12:18 PM   Resolved: 20/Oct/10 08:16 PM
Component/s: Queries
Affects Version/s: 2.1.0.release
Fix Version/s: 2.2.0.m3

File Attachments: 1. Zip Archive testcase.zip (3 kB)


Datastore: MySQL


 Description  « Hide
Running query "SELECT FROM org.datanucleus.test.A WHERE list.contains(this) PARAMETERS java.util.Collection list". If "list" Collection contains instance of type B (completely uncorrelated with A) and id of that instance happens to be the same of some other instance of type A query returns that instance of A. Supposedly the result should be always empty in such cases.

From Java Data Objects 2.2 spec, 14.6.2 "equality comparison among persistent instances of persistence-capable types use the JDO Identity comparison of the references; this includes containment methods applied to Collection and Map types. Thus, two objects will compare equal if they have the same JDO Identity."

Perhaps this can be prevented by filtering collection passed in as a parameter, leaving only types compatible with candidate classes.

Sort Order: Ascending order - Click to sort in descending order
Areg Beketovski added a comment - 24/Jun/10 03:18 PM
Testcase demonstrating the issue.

Andy Jefferson added a comment - 23/Sep/10 02:11 PM
When saying that some JDOQL doesn't work as expected, I'd expect a quote of the JDOQL and the associated SQL, since that gives basis for discussion

Andy Jefferson added a comment - 20/Oct/10 08:10 PM
User queries of the form provided are simply user error, and needing a validity check, so don't qualify as "Major" importance

Andy Jefferson added a comment - 20/Oct/10 08:16 PM
Works for me with SVN trunk, adding a "1 = 0" where clause.