Using the FixtureAdapter, removing an object from a hasMany relationship removes all objects #684

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

Projects

None yet

5 participants

@jergason
jergason commented Feb 1, 2013

Steps to reproduce:

  1. Create a store using the FixtureAdapter
  2. Create a hasMany relationship between the two models
  3. Obtain one of the members of the hasMany relationships
  4. Call removeObject on the model that has the hasMany relationship
  5. Notice that all members of the hasMany relationship are gone from the UI.

See the JSFiddle for a demo. Click the "Delete From Tab Items" button and notice all the items disappear.

@ianpetzer

This also seems to occur when you add a new record to the hasMany relationship and commit it to the store.

As documented here: http://stackoverflow.com/questions/14587572/ember-data-fixtureadapter-commiting-new-record-to-hasmany-association-causes-e

@salper
salper commented Feb 11, 2013

When the parent record is saved using updateRecord, it is serialized without the relationships meta values. I tried to fix this using the embedded configuration of the serializer, but it raised another error deeper. The following did the trick for me, but I'm waiting for a proper fix :

   return DS.FixtureAdapter.create({
      /**
       * Overridden, otherwise, fixtures adapter
       * erases the hasMany data during update.
       *
       * @todo waiting for an ember fix
       */
      updateRecord : function(store, type, record) {
         var fixture = this.mockJSON(type, record);
         this.simulateRemoteCall(function() {
            store.didSaveRecord(record);
         }, store, type, record);
      }
   });
@sly7-7
Contributor
sly7-7 commented May 3, 2013

like #683 it looks like it's fixed: http://jsfiddle.net/Sly7/vm8YU/

@stefanpenner
Member

as usual @sly7-7 thank you! 🍻

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