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

Changing a parent then unload a child record clears the hasMany relationship current state of the parent #6146

Closed
lsg-braymon opened this issue Jun 4, 2019 · 1 comment

Comments

@lsg-braymon
Copy link
Contributor

lsg-braymon commented Jun 4, 2019

Reproduction

Description

  1. Model setup:
    class Person extends Model {
      @hasMany('pet', { inverse: 'owner', async: false })
      pets;
      @attr()
      name;
    }
    
    class Pet extends Model {
      @belongsTo('person', { inverse: 'pets', async: false })
      owner;
      @attr()
      name;
    }
  2. Data:
    personA:
      pets: petA
    
    personB:
      pets: petB
    
  3. Update the owner of petB so that it is now owned by personA:
    petB.set("owner", personA)
    
    // It will result in the following relatioships:
    personA.pets // [petA, petB]
    personB.pets // []
  4. Unload the original pet of personA which is petA: petA.unloadRecord().
  5. Inspect the relationships:
    petB.owner // personA
    personA.pets // BUG: this is now empty. The expected result is [petB]

Versions

Run the following command and paste the output below: npm ls ember-source && npm ls ember-cli && npm ls ember-data.

ember-source@3.10.0
ember-source@3.10.0
ember-data@3.11.0-beta.1

We were also using ember-data@3.10.0 before and the issue is also present in that version.

@runspired
Copy link
Contributor

This was fixed at some point with all of the relationship layer cleanup :)

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

No branches or pull requests

2 participants