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

Warn when findRecord returns a different id than the one requested #4604

Merged
merged 1 commit into from
Oct 20, 2016
Merged

Warn when findRecord returns a different id than the one requested #4604

merged 1 commit into from
Oct 20, 2016

Conversation

pangratz
Copy link
Member

This addresses the problem stumbled over in #4414.

Basically we can't assert here as this would be a breaking change, since the bug mostly will not occur unless you try to reload the originally requested record again.

cc @igorT

@igorT igorT merged commit f5a02cd into emberjs:master Oct 20, 2016
@pangratz pangratz deleted the warn-on-mismatched-id branch October 20, 2016 17:48
@@ -38,6 +38,11 @@ export function _find(adapter, store, typeClass, id, internalModel, options) {
return store._adapterRun(function() {
var payload = normalizeResponseHelper(serializer, store, typeClass, adapterPayload, id, 'findRecord');
assert('Ember Data expected the primary data returned from a `findRecord` response to be an object but instead it found an array.', !Array.isArray(payload.data));

warn(`You requested a record of type '${typeClass.modelName}' with id '${id}' but the adapter returned a payload with primary data having an id of '${payload.data.id}'. Looks like you want to use store.queryRecord instead http://emberjs.com/api/data/classes/DS.Store.html#method_queryRecord`, payload.data.id === id, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried that out of the box store.queryRecord doesn't solve this problem out of the box and the documentation linked isn't doesn't point the user toward an actionable fix for the problem this is warning about.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I see your concern 😔 . But I don't see how this issue could be solved other than queryRecord. I will try to update the docs and this warning...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #4609

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.

3 participants