[#425] Fix Dataset.query() when called with Query model
The problem is that Backbone >= 0.9.9 doesn't accept updating models with:
model.set(otherModel);
That needs to be changed to:
model.set(otherModel.attributes);
Dataset.query() accepts both regular JS objects and Query models, so we need to
check the parameter type to support both.
This commit is contained in:
@@ -177,6 +177,31 @@ test('Dataset getFieldsSummary', function () {
|
||||
});
|
||||
});
|
||||
|
||||
test('query with Query model', function () {
|
||||
var dataset = new recline.Model.Dataset({
|
||||
records: [{country: 'UK'}, {country: 'DE'}]
|
||||
});
|
||||
var query = new recline.Model.Query();
|
||||
query.addFilter({type: 'term', field: 'country', term: 'DE'});
|
||||
|
||||
dataset.query(query).done(function (results) {
|
||||
deepEqual(results.length, 1);
|
||||
deepEqual(results.models[0].toJSON(), {country: 'DE'});
|
||||
});
|
||||
});
|
||||
|
||||
test('query with plain object', function () {
|
||||
var dataset = new recline.Model.Dataset({
|
||||
records: [{country: 'UK'}, {country: 'DE'}]
|
||||
});
|
||||
var query = {q: 'DE'};
|
||||
|
||||
dataset.query(query).done(function (results) {
|
||||
deepEqual(results.length, 1);
|
||||
deepEqual(results.models[0].toJSON(), {country: 'DE'});
|
||||
});
|
||||
});
|
||||
|
||||
test('fetch without and with explicit fields', function () {
|
||||
var dataset = new recline.Model.Dataset({
|
||||
backend: 'csv',
|
||||
|
||||
Reference in New Issue
Block a user