Skip to content

Commit

Permalink
Apply dojo/store/util/QueryResults in DstoreAdapter whether options a…
Browse files Browse the repository at this point in the history
…re passed to query or not.
  • Loading branch information
edhager authored and kriszyp committed Mar 20, 2015
1 parent 9a4a777 commit fd3d734
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
9 changes: 6 additions & 3 deletions legacy/DstoreAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ define([

var results = this.store.filter(query);
var queryResults;
var tracked;
var total;

// Apply sorting
var sort = options.sort;
Expand All @@ -108,7 +110,6 @@ define([
}
}

var tracked;
if (results.track && !results.tracking) {
// if it is trackable, always track, so that observe can
// work properly.
Expand All @@ -123,9 +124,11 @@ define([
start: start,
end: options.count ? (start + options.count) : Infinity
});
queryResults.total = queryResults.totalLength;
}
queryResults = queryResults || new QueryResults(results[results.fetchSync ? 'fetchSync' : 'fetch']());
queryResults = queryResults || results[results.fetchSync ? 'fetchSync' : 'fetch']();
total = queryResults.totalLength;
queryResults = new QueryResults(queryResults);
queryResults.total = total;
queryResults.observe = function (callback, includeObjectUpdates) {
// translate observe to event listeners
function convertUndefined(value) {
Expand Down
10 changes: 10 additions & 0 deletions tests/legacy/DstoreAdapter-Rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ define([
i++;
assert.strictEqual(object.name, 'node' + i);
});
},
'query iterative with options': function () {
mockRequest.setResponseText(treeTestRootData);

var i = 0;
return store.query('data/treeTestRoot', { start: 0 }).map(function (object) {
i++;
assert.strictEqual(object.name, 'node' + i);
return object;
});
}
});
});

0 comments on commit fd3d734

Please sign in to comment.