-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix: Don't notify changes for attributes not registered with the schema #9698
Conversation
@@ -557,10 +557,12 @@ export default class JSONAPICache implements Cache { | |||
this._capabilities.notifyChange(identifier, 'state', null); | |||
} | |||
|
|||
const fields = this._capabilities.schema.fields(identifier); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically I could only set this if one of the conditions below are met and we know we'll need it. Don't want to over-optimize
@@ -1740,7 +1740,7 @@ class Model extends EmberObject implements MinimalLegacyRecord { | |||
this.eachComputedProperty((name, meta) => { | |||
if (isAttributeSchema(meta)) { | |||
assert( | |||
"You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: attr('<type>')` from " + | |||
"You may not set 'id' as an attribute on your model. Please remove any lines that look like: `id: attr('<type>')` from " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making this error message match the other one so the tests don't care about where specifically the error is thrown.
test('_push does not require a modelName to resolve to a modelClass', function (assert) { | ||
const store = this.owner.lookup('service:store'); | ||
const originalCall = store.modelFor; | ||
store.modelFor = function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chris says we don't need this optimization anymore.
Description
Fixes a bug where we would notify changes to data that wasn't actually registered with the schema. This seems to only cause issues if the data is coincidentally tracked for some other reason (e.g.
id
or a tracked property with the same name).NOTE:
Currently (including with this change), we do not discard this data in the cache. So when you get the resource data out of the cache, we include it. Since some APIs are dependent on payloads being complete when you send them back, some users may rely on the current behavior. So we don't delete the value itself so that it's still merged in. We should probably deprecate this eventually.
Notes for the release