Issue Details (XML | Word | Printable)

Key: NUCRDBMS-689
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Thierry Monney
Votes: 0
Watchers: 0
Operations

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

JDO query with "param == null" condition generates bad SQL

Created: 29/Aug/13 02:01 PM   Updated: 03/Sep/13 03:40 PM   Resolved: 30/Aug/13 03:55 PM
Component/s: Queries
Affects Version/s: 3.2.5
Fix Version/s: 3.2.6

Forum Thread URL: http://www.datanucleus.org/servlet/forum/viewthread_thread,7579
Datastore: HSQL


 Description  « Hide
The following JDO query:

Query query = pm.newQuery(Person.class);
query.setFilter("pName == null || name == pName");
query.declareParameters("java.lang.String pName");

Generates the following SQL
SELECT 'ch.thierry.datanucleus.Person' AS NUCLEUS_TYPE,A0.ID,A0."NAME",A0.PERSON_ID FROM PERSON A0 WHERE (? = NULL) OR (A0."NAME" = ?)

That should be
SELECT 'ch.thierry.datanucleus.Person' AS NUCLEUS_TYPE,A0.ID,A0."NAME",A0.PERSON_ID FROM PERSON A0 WHERE (? IS NULL) OR (A0."NAME" = ?)

Test case is at https://github.com/thierrymonney/datanucleus-null-param-query


Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 30/Aug/13 03:55 PM
SVN trunk supports String parameter ==/!=