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

Missing id warning #98

Closed
kenjiqq opened this issue Jul 20, 2014 · 7 comments
Closed

Missing id warning #98

kenjiqq opened this issue Jul 20, 2014 · 7 comments
Assignees
Milestone

Comments

@kenjiqq
Copy link

kenjiqq commented Jul 20, 2014

There does not seem to be any errors or warning of you define a idAttribute that the resource you fetch from the server does not contain. Should probably be some warning that the id was not found. Right now it just doesn't inject any of the objects into the store so you just get an empty array from a filter query etc

@jmdobry
Copy link
Member

jmdobry commented Jul 20, 2014

Is this when you use DS.findAll?

DS.inject throws a RuntimeError if the idAttribute defined by the resource is not present in the attrs argument. DS.inject is used internally by find, findAll, create, save, and update. Are you not seeing any error message from the error thrown by DS.inject?

Perhaps you could provide some sample code or a Plunker/JSBin/JSFiddle that demonstrates the issue?

@kenjiqq
Copy link
Author

kenjiqq commented Jul 20, 2014

You figured it out? Was just trying to make a jsbin to show it

@jmdobry
Copy link
Member

jmdobry commented Jul 20, 2014

In any case, I verified that the error is thrown, and added a $log.error if for some reason the thrown error is not printed by the console. In fact, if a response to a DS.findAll call contains items that are missing the field specified by the resource's idAttribute, then the promise will be rejected, as shown in this test here https://github.com/jmdobry/angular-data/blob/master/test/integration/datastore/async_methods/findAll.test.js#L87

@jmdobry jmdobry added this to the 0.10.1 milestone Jul 20, 2014
@jmdobry
Copy link
Member

jmdobry commented Jul 20, 2014

Fixed as of 0.10.1.

@jmdobry jmdobry self-assigned this Jul 20, 2014
@jmdobry jmdobry added bug and removed question labels Jul 20, 2014
@kenjiqq
Copy link
Author

kenjiqq commented Jul 20, 2014

http://jsbin.com/rogadaho/2/edit?html,js,console here is a jsBin that demonstrates the problem if you need it. No errors here, but if you change to the other id attribute it works fine

@jmdobry
Copy link
Member

jmdobry commented Jul 20, 2014

Thanks. If you change https://github.com/jmdobry/angular-data/releases/download/0.10.0/angular-data-0.10.0.js to https://github.com/jmdobry/angular-data/releases/download/0.10.1/angular-data-0.10.1.js in your JSBin you'll see the error reported to your console.

@kenjiqq
Copy link
Author

kenjiqq commented Jul 20, 2014

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants