Calling deleteRecord on a model that is a member of a hasMany relationship on another model doesn't remove the relationship using FixtureAdapter #683

Closed
jergason opened this Issue Feb 1, 2013 · 6 comments

Projects

None yet

4 participants

@jergason
jergason commented Feb 1, 2013

Apologies if this is me doing something wrong or an Ember issue not a Data one, but here is what I am seeing:

Steps to reproduce:

  1. Create a store using the FixtureAdapter
  2. Create a model with a hasMany relationship to another model
  3. Create fixture data for both these models
  4. Call deleteRecord() and then store.commit() on one of the members of the hasMany relationship
  5. Notice how the parent model's hasMany relationship doesn't update, which makes the UI not update.

I expect that deleting the member of the hasMany relationship would make the parent update it's hasMany array, which would update the template and remove the deleted child item from the DOM.

See JSFiddle for this issue. Clicking the Delete Record button calls deleteRecord the first time, but doesn't actually update the view.

@ahawkins
Contributor
ahawkins commented Feb 1, 2013

Fixture adapter does not persist any changes. Why..I don't know. This isn't a bug. This is how it's programmed.

@jergason
jergason commented Feb 1, 2013

But it allows you to add records, and those are reflected in the UI. Why is
deleting records any different?

On Fri, Feb 1, 2013 at 11:41 AM, Adam Hawkins notifications@github.comwrote:

Fixture adapter does not persist any changes. Why..I don't know. This
isn't a bug. This is how it's programmed.


Reply to this email directly or view it on GitHubhttps://github.com/emberjs/data/issues/683#issuecomment-13007676.

@ahawkins
Contributor
ahawkins commented Feb 1, 2013

They are added kept in the store. The fixture adapter just says: yes store, I did save that. If you create a record it will not be saved into .FIXTURES either. The fixture adapter doesn't actually save anything on create/update/delete. It just says it did.

@jergason
jergason commented Feb 1, 2013

Why does it throw an error when you click the delete button twice if it is
not actually deleted then?

On Fri, Feb 1, 2013 at 11:50 AM, Adam Hawkins notifications@github.comwrote:

They are added kept in the store. The fixture adapter just says: yes
store, I did save that. If you create a record it will not be saved into
.FIXTURES either. The fixture adapter doesn't actually save anything on
create/update/delete. It just says it did.


Reply to this email directly or view it on GitHubhttps://github.com/emberjs/data/issues/683#issuecomment-13008136.

@ahawkins
Contributor
ahawkins commented Feb 1, 2013

EDIT. I think we are talking about different things. My comments are about removing an item from the .FIXTURES array. If you are talking about that them my comments are relavant, otherwise you can ignore them. Sorry about that.

It's also highly likely there is a problem in the fixture adapter. It sounds like everything is working partially correct. The record is being destroyed correctly the first time. Just the arrays themselves are not updating correctly. Also from what I've seen, simply destroying it doesn't not remove it from the association. It simply exists as a destroyed record. I'm not sure if you have to remove manually.

@sly7-7
Contributor
sly7-7 commented May 3, 2013

@jergason it looks like it behaves correcty now. see http://jsfiddle.net/Sly7/vm8YU/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment