lundi 2 juillet 2018

Upgrading to Ember-Data 2.14 broke computed filter on hasMany

I have tried reproducing this problem in a twiddle but unfortunately the twiddle always succeeds, but I'm hoping the error might sound familiar to someone and they can point me in the right direction.

Here's the twiddle: https://ember-twiddle.com/9ee6f28479449b7b1859e4c090490775?openFiles=routes.parent.js%2C

All the names have been changed to make our data security folks feel better:

The basics: I have a model 'parent' with an async 'hasMany' relation to 'child'.

children: hasMany('child', {async: true}),

I then have a computed property bound to the hasMany:

sons: Ember.computed.filterBy('children', 'type', 'son'),

I then alias firstObject to get the first item in the 'sons' array:

firstSon: Ember.computed.alias('sons.firstObject')

In the parent route.setupController, I create a new 'son' object:

setupController: function(controller, model) {
    this._super(...arguments);
    var toy = this.get('store').createRecord('toy', {
      type: 'latte'
    });
    this.get('store').createRecord('child',
        {parent: model, type: 'son', toy: toy,
        name: 'Tyler'});
  }

With Ember 2.14 and Ember-Data 2.13, or any lower combination of matching versions, this works and my template can refer to parent.firstSon with no problems.

As soon as I upgrade Ember-Data to 2.14, when I reach my desired route, parent.children has the correct child but the sons: filterBy is empty and therefore the alias to sons.firstObject is also empty. (as validated through Ember inspector)

Reminder: the twiddle I linked does actually work, it's the more complicated version in my app that fails.

The simple act of upgrading breaks it - no other code changes occur.

I've seen some similar issues in ember-data github: This issue: https://github.com/emberjs/data/issues/4974 is similar but it seems to start at 2.12 and seems tied to the newish 'hasMany' call that avoids loading data. I'm simply binding to the actual async hasMany

https://github.com/emberjs/ember.js/issues/16258 references a similar problem, but one that only starts with Ember 3.0.0 and isn't present in 2.18 - My problem happens from 2.14.1 through ~2.18

Any thoughts on what might have broken?




Aucun commentaire:

Enregistrer un commentaire