emberfire icon indicating copy to clipboard operation
emberfire copied to clipboard

Bug with saving embedded models inside embedded models

Open emoryy opened this issue 8 years ago • 0 comments

There seems to be problems with saving embedded models. When you have embedded models inside embedded models, then the third level models will be only persisted to the database with the first save after the app loaded. If after a first save you add/remove third level models, then saving the top level model won't have any effect.

Version info

DEBUG: -------------------------------
DEBUG: Ember      : 2.13.2
DEBUG: Ember Data : 2.13.1
DEBUG: Firebase   : 3.9.0
DEBUG: EmberFire  : 0.0.0
DEBUG: jQuery     : 3.2.1
DEBUG: -------------------------------

Test case

I've put together a simple app for trying out the scenario: https://github.com/emoryy/emberfire-embedded-model-error I used ember-cli-dotenv, so put the variables of a test Firebase project into a .env file into the root of the cloned repo like this:

apiKey=xxx
authDomain=xxx
databaseURL=xxx
projectId=xxx
storageBucket=xxx
messagingSenderId=xxx

I didn't put authentication handling into the app, so the database needs to be publicly writable.

To run the app: npm install && bower install && ember s or yarn && bower install && ember s

In the test app there are models named Parent, Child, GrandChild. Child is embedded into Parent, GrandChild is embedded into Child with hasMany relationships

The app provides buttons to create/remove the above models, and a save button that calls save on all Parent models.

Steps to reproduce

In the test app:

  1. Add Parent models
  2. Add Child models
  3. Add GrandChild models
  4. Press save
  5. Add some more GrandChild models (or remove some)
  6. Press Save
  7. Reload the page

Expected behavior

The modifications performed regarding GrandChild models in step 5 should be seen after saving and reloading the page.

Actual behavior

The modifications performed regarding GrandChild models in step 5 can't be seen after saving and reloading the page.

emoryy avatar May 31 '17 20:05 emoryy