forked from datopian/datahub
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[datopian#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.
- Loading branch information
1 parent
fa1e4d3
commit b26f270
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,7 +191,11 @@ my.Dataset = Backbone.Model.extend({ | |
this.trigger('query:start'); | ||
|
||
if (queryObj) { | ||
this.queryState.set(queryObj, {silent: true}); | ||
var attributes = queryObj; | ||
if (queryObj instanceof my.Query) { | ||
attributes = queryObj.toJSON(); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
vitorbaptista
Author
Owner
|
||
} | ||
this.queryState.set(attributes, {silent: true}); | ||
} | ||
var actualQuery = this.queryState.toJSON(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Think this shoudl be fine but note sometimes toJSON does something fancy and I think it could be better to do queryObj.attributes but think this is fine for now ...