Opened 11 years ago

Closed 11 years ago

#7989 closed defect (fixed)

dojox.data.ClientFilter: querySuperSet function returns successful if query is not an object

Reported by: dustint Owned by: Kris Zyp
Priority: high Milestone: 1.3
Component: DojoX Data Version: 1.2.0
Keywords: Cc:
Blocked By: Blocking:

Description

Take the following example: dojox.store.ServiceStore?.fetch({[Error: Query filter requires field and constraints separated by a "="]}); dojox.store.ServiceStore?.fetch({[Error: Query filter requires field and constraints separated by a "="]});

Now, when we call the fetch for the query of 2, we test to see if the queries are the same: argsSuper.query == argsSub.query, which won't evaluate to true because 1 != 2

However, then we try to mixin the query: dojo.mixin({},1) which doesnt make any sense, so we never get to the return false logic and end up returning the clientQuery, resulting in success.

To fix this, we should wrap the mixin and following code with tests to ensure the queries are actually objects. Eg:

if(typeof argsSub.query == 'object' && argsSub.query == 'object'){

var clientQuery = dojo.mixin({},argsSub.query); for(var i in argsSuper.query){

if(clientQuery[i] == argsSuper.query[i]){

delete clientQuery[i];

}else if(!(typeof argsSuper.query[i] == 'string' && dojo.data.util.filter.patternToRegExp(argsSuper.query[i]).test(clientQuery[i]))){

return false;

}

}

}else{

return false;

}

Change History (9)

comment:1 Changed 11 years ago by Jared Jurkiewicz

Owner: changed from Jared Jurkiewicz to kriszyp

comment:2 Changed 11 years ago by Jared Jurkiewicz

Owner: changed from kriszyp to Kris Zyp

comment:3 Changed 11 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

(In [16456]) Fixes #7989

comment:4 Changed 11 years ago by dante

Milestone: tbd1.3
Resolution: fixed
Status: closedreopened

comment:5 Changed 11 years ago by dante

Resolution: fixed
Status: reopenedclosed

fixing milestone.

comment:6 Changed 11 years ago by Jared Jurkiewicz

Resolution: fixed
Status: closedreopened

This seems to break unit tests for ClientFilter? see:

util/doh/runner.html?testModule=dojox.data.tests.module

Errors in firebug:


GROUP "dojox.data.tests.ClientFilter?" has 4 tests to runbootstrap.js (line 529) updateWhileLoading Object firstName=Jack lastName=Smith Object firstName=Jack lastName=Smith PASSED test: updateWhileLoading 0 msbootstrap.js (line 529) sent first sent seconds items[4] Object firstName=Jack lastName=Smith items first [Object firstName=John lastName=Smith id=mock/1, Object firstName=Jim lastName=Smith id=mock/2, Object firstName=Jill lastName=Smith id=mock/3, Object firstName=Jerry lastName=Smith id=mock/4, Object firstName=Jack lastName=Smith] Error: test timeout in makeChanges message=test timeout in makeChangesbootstrap.js (line 529) ERROR IN: (function makeChanges(t) {var d = new doh.Deferred;jsonStore.fetch({queryOptions:{cache:true}, query:{lastName:"Smith", firstName:"*"}, sort:[{attribute:"firstName", descending:true}], onComplete:function (items, request) {t.is(5, items.length);t.is(newJack, items[4]);console.log("items[4]", items[4]);var newJoe = jsonStore.newItem({firstName:"Joe", lastName:"Smith"});t.is(5, items.length);jsonStore.updateResultSet(items, request);t.is(6, items.length);t.is(newJoe, items[1]);var jackJones = jsonStore.newItem({firstName:"Jack", lastName:"Jones"});jsonStore.updateResultSet(items, request);t.is(6, items.length);jsonStore.setValue(newJoe, "firstName", "Jesse");jsonStore.updateResultSet(items, request);t.is(6, items.length);t.is(newJoe, items[3]);t.f(newJoe == items[1]);jsonStore.deleteItem(newJack);jsonStore.updateResultSet(items, request);t.is(5, items.length);jsonStore.setValue(newJoe, "lastName", "Baker");jsonStore.updateResultSet(items, request);t.is(4, items.length);jsonStore.setValue(jackJones, "lastName", "Smith");jsonStore.updateResultSet(items, request);t.is(5, items.length);}});console.log("sent first");var finished;jsonStore.fetch({query:{lastName:"Smith", firstName:"Jack"}, sort:[{attribute:"firstName", descending:true}], onComplete:function (items, request) {console.log("items first", items);finished = true;t.is(1, items.length);d.callback(true);}});console.log("sent seconds");t.f(finished);return d;})bootstrap.js (line 529) FAILED test: makeChanges 0 msbootstrap.js (line 529) items [Object firstName=John lastName=Smith id=mock/1, Object firstName=Jim lastName=Smith id=mock/2, Object firstName=Jill lastName=Smith id=mock/3, Object firstName=Jerry lastName=Smith id=mock/4, Object firstName=Jack lastName=Smith] _AssertFailure: file:///X:/dojo/trunk/dojo/_base/_loader/bootstrap.js:538 doh._AssertFailure: assertTrue('undefined') failedbootstrap.js (line 529) doh._AssertFailure message=assertTrue('undefined') failedbootstrap.js (line 529) ERROR IN: (function cachedResults(t) {var d = new doh.Deferred;var finished;jsonStore.fetch({query:{lastName:"Smith", firstName:"Jack"}, sort:[{attribute:"firstName", descending:true}], onComplete:function (items, request) {console.log("items", items);finished = true;t.is(1, items.length);d.callback(true);}});t.t(finished);return d;})bootstrap.js (line 529) FAILED test: cachedResults 0 msbootstrap.js (line 529) last name: John Object firstName=John lastName=Smith id=mock/1 first name Jack Object firstName=Jack lastName=Smith _AssertFailure: file:///X:/dojo/trunk/dojo/_base/_loader/bootstrap.js:538 doh._AssertFailure: assertTrue('undefined') failedbootstrap.js (line 529) doh._AssertFailure message=assertTrue('undefined') failedbootstrap.js (line 529) ERROR IN: (function sorting(t) {var d = new doh.Deferred;var finished;jsonStore.fetch({query:{lastName:"Smith", firstName:"*"}, sort:[{attribute:"firstName", descending:true}], onComplete:function (items, request) {var last = jsonStore.getValue(items[0], "firstName");console.log("last name: ", last, items[0]);t.is("John", last);jsonStore.fetch({query:{lastName:"Smith", firstName:"*"}, sort:[{attribute:"firstName"}], onComplete:function (items, request) {var first = jsonStore.getValue(items[0], "firstName");console.log("first name", first, items[0]);finished = true;t.is("Jack", first);d.callback(true);}});}});t.t(finished);return d;})bootstrap.js (line 529) FAILED test: sorting 0 msbootstrap.js (line 529)


comment:7 Changed 11 years ago by Jared Jurkiewicz

You can just run: file:///X:/dojo/trunk/util/doh/runner.html?testModule=dojox.data.tests.ClientFilter

And see the failures.

Reverting back to previous level (r15758) does not show the failures.

comment:8 Changed 11 years ago by Jared Jurkiewicz

Correction, the previous revision was: r15937

Which passed tests.

r16456 does not pass tests.

comment:9 Changed 11 years ago by Kris Zyp

Resolution: fixed
Status: reopenedclosed

I reverted back to r15937, this issue had actually been fixed several months ago.

Note: See TracTickets for help on using tickets.