Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#9397 closed defect (fixed)

JsonQuery + dojo.data item + Persevere (not in default context) = invalid jsonQuery string

Reported by: seangarner Owned by: Kris Zyp
Priority: high Milestone: 1.4
Component: DojoX Data Version: 1.3.0
Keywords: jsonQuery Cc:
Blocked By: Blocking:

Description

Hi

jsonQuery is directly using the dojo.data.item.__id when building a query string. This is normally ok but when the dataSource target is not in a root context (e.g. /data/Class/Id) then using the __id would be inappropriate.

An example best serves to demonstrate; the first will result in a correct jsonQuery string [?(@.prop='Friends/1')]

// Assuming that 'item' is a dojo.data.item instance and it has an id of 1
store = new dojox.data.PersevereStore('/Friends');
store.fetch( { query: { bestFriend: item } } );

This time we set the target of the store to a non-root location and it will result in the following invalid jsonQuery string [?(@.prop='/data/Friends/1')]

// Assuming that 'item' is a dojo.data.item instance and it has an id of 1
store = new dojox.data.PersevereStore('/data/Friends');
store.fetch( { query: { bestFriend: item } } );

When persisting data using the same store (dojox.data.PersevereStore) it does strip the non default context when saving it which makes me think that the behaviour in jsonQuery is wrong.

Attachments (1)

JsonQuery.js.patch (699 bytes) - added by seangarner 10 years ago.
Fix that works for me

Download all attachments as: .zip

Change History (7)

Changed 10 years ago by seangarner

Attachment: JsonQuery.js.patch added

Fix that works for me

comment:1 Changed 10 years ago by seangarner

The patch I've attached fixes the JSON Reference not being correctly generated and also adds in a flag that it's a data item and thus shouldn't be treated as case insensitive (~)

comment:2 Changed 10 years ago by Jared Jurkiewicz

Owner: changed from Jared Jurkiewicz to Kris Zyp

Assigning to Kris Zyp for review/consideration.

comment:3 Changed 10 years ago by seangarner

Interestingly you have to download that patch in its original format, it doesn't seem to display in trac.

That aside, there's a bug in the patch, just after appending to the jsonQuery and before first = false; isDataItem needs to be reset to false or it will cause all items following a dojo.data.item to use = instead of ~ when specified in queryOptions.ignoreCase.

comment:4 Changed 10 years ago by Kris Zyp

(In [18384]) Makes JSONQuery always use case-sensitive comparison '=' for id comparisons. refs #9397

comment:5 Changed 10 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

I applied the patch for using '=' when appropriate, but doesn't the flag "useFullIdInQueries" imply that the full absolute path of the objects should be used in the queries (as it is)?

comment:6 Changed 10 years ago by Adam Peller

Milestone: tbd1.4
Note: See TracTickets for help on using tickets.