Closed steffann closed 10 years ago
One idea to solve this is to grab the related object directly from data
:
get(record, 'data.' + relationship.key)
The .map()
only calls this.relationshipToResourceUri(relationship, next)
, which only uses the id
property of the passed object. That id
value has always been filled, even if the rest of the object hasn't been async-loaded yet.
This also means it is unnecessary to load the whole referenced object just to be able to save a reference to it, which is an added bonus.
It makes sense. Do you mind putting a PR together so we can keep your contribution?
If not, I'll try to update the adapter as soon as possible. Which version of ED are you using? I am finding issues to upgrade to Beta9 and it's related to IDs.
Thanks!
I'll prepare the PR for this one.
I'm at beta9 at the moment and I haven't run into any issues except this one (yet).
PR at #37
I'll try to manage to get the tests working at all here so I can test before I send something in. I use async mode a lot, and I suspect that the failures have something to do with that...
There is a serialisation error for hasMany relationships. The
get(record, relationship.key)
at https://github.com/escalant3/ember-data-tastypie-adapter/blob/master/packages/ember-data-tastypie-adapter/lib/tastypie_serializer.js#L212 can return a promise. The.map()
on that returns an empty array, which is then sent in the request and deletes all the corresponding relationships on the server...