Skip to content

Commit

Permalink
Merge pull request #4609 from pangratz/doc-improve-warning-for-mismat…
Browse files Browse the repository at this point in the history
…ch-id

[DOC] Improve warning for mismatched id in store.findRecord
  • Loading branch information
bmac authored Oct 21, 2016
2 parents 41193f7 + effe89d commit bae01b8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions addon/-private/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,8 @@ Store = Service.extend({

/**
This method makes a request for one record, where the `id` is not known
beforehand (if the `id` is known, use `findRecord` instead).
beforehand (if the `id` is known, use [`findRecord`](#method_findRecord)
instead).
This method can be used when it is certain that the server will return a
single object for the primary data.
Expand Down Expand Up @@ -1208,8 +1209,7 @@ Store = Service.extend({
The request is made through the adapters' `queryRecord`:
```javascript
// app/adapters/user.js
```app/adapters/user.js
import DS from "ember-data";
export default DS.Adapter.extend({
Expand Down
2 changes: 1 addition & 1 deletion addon/-private/system/store/finders.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function _find(adapter, store, typeClass, id, internalModel, options) {
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, {
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}'. Use 'store.findRecord()' when the requested id is the same as the one returned by the adapter. In other cases use 'store.queryRecord()' instead http://emberjs.com/api/data/classes/DS.Store.html#method_queryRecord`, payload.data.id === id, {
id: 'ds.store.findRecord.id-mismatch'
});

Expand Down

0 comments on commit bae01b8

Please sign in to comment.