Issue Details (XML | Word | Printable)

Key: NUCRDBMS-388
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Peter Dettman
Votes: 0
Watchers: 0
Operations

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

JDOQL2: Passing null parameter value results in incorrect SQL

Created: 14/May/10 05:46 AM   Updated: 24/May/10 03:43 PM   Resolved: 17/May/10 08:59 AM
Component/s: Queries
Affects Version/s: 2.1.0.m2
Fix Version/s: 2.1.0.m3

Datastore: PostgreSQL


 Description  « Hide
Querying a simple class Box, with a nullable recursive field 'parent':

    Query test = pm.newQuery(Box.class);
    test.setResult("id");
    test.setFilter("parent == :parent");
    test.execute(null);

JDOQL-Legacy works fine, returning the expected rows. Logs show this was executed:
SELECT this.id FROM box this WHERE this.parent_id IS NULL

JODQL(2) returns no rows (but no error is raised). Logs show this was executed:
SELECT a0.id FROM box a0 LEFT OUTER JOIN box b0 ON a0.parent_id = b0.id WHERE b0.id = <null>

The query works fine when parent is not null.

Using a literal 'null' in the query works too i.e.

    Query test = pm.newQuery(Box.class);
    test.setResult("id");
    test.setFilter("parent == null");
    test.execute();

although the SQL is a bit weird (JDOQL2):

    SELECT a0.id FROM box a0 LEFT OUTER JOIN box b0 ON a0.parent_id = b0.id WHERE b0.id IS NULL





Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 17/May/10 08:59 AM
Works for me with SVN trunk. Add a testcase that demonstrates this if not working with current code

Peter Dettman added a comment - 19/May/10 12:54 PM
Thanks Andy, confirm it's working for me with SVN trunk.