Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handleFindQuery json payload must be an array #45

Merged

Conversation

ksykulev
Copy link
Contributor

I noticed that if you do not pass in an array into handleFindQuery stuff breaks somewhat silently and ember data returns no results. Seems like an obvious one, but I added a small validation so people don't get confused.

var car = FactoryGuy.build('car'); //single car { id: 1, name: 'Model S', year: 2014 }
testHelper.handleFindQuery('car', ['year', 'name'], car); 

We get into extractArray, and map.call(payload[prop]) executes over an object and it returns an empty array.

extractArray: function(store, primaryType, rawPayload) {
...
  var normalizedArray = map.call(payload[prop], function(hash) {
    return typeSerializer.normalize(type, hash, prop);
  }, this);
...
}

When passing json as the payload to handleFindQuery, this asserts that
it's an array. Otherwise we get some odd behavior from ember data
because it expects an array.
danielspaniel added a commit that referenced this pull request Dec 28, 2014
handleFindQuery json payload must be an array
@danielspaniel danielspaniel merged commit cd80fbb into adopted-ember-addons:master Dec 28, 2014
@ksykulev ksykulev deleted the handleFindQuery-json-array branch January 10, 2015 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants