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

@ember-data/record-data RecordData.isEmpty implementation should consider isNew in calculation #7844

Closed
runspired opened this issue Jan 12, 2022 · 1 comment · Fixed by #7902
Labels
🏷️ bug This PR primarily fixes a reported issue

Comments

@runspired
Copy link
Contributor

The implementation is here: Source

 // this is a hack bc we don't have access to the state machine
  //   and relationships need this info and @runspired didn't see
  //   how to get it just yet from storeWrapper.
  isEmpty() {
    return this.__attributes === null && this.__inFlightAttributes === null && this.__data === null;
  }

This leads to a bug whereby store.createRecord('user') (note the lack of any second arg) can incorrectly trigger fetches for relationships with the new user record because the internals consider empty records to be fetchable. It also means that in more recent ember-data versions records begin their life isEmpty if created in this way, as we now pull this state from the RecordData instance.

@runspired
Copy link
Contributor Author

cc @kategengler

@runspired runspired moved this to Fix | TODO in EmberData Feb 18, 2022
Repository owner moved this from Fix | TODO to RFC | Needs Implemented in EmberData Apr 30, 2022
@runspired runspired added 🏷️ bug This PR primarily fixes a reported issue and removed Bug labels Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bug This PR primarily fixes a reported issue
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant