adopted-ember-addons / adopted-ember-addons/ember-data-model-fragments

default value on fragmentArray not working

オープン
#238 コメント 5 件 リアクション 2 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
367
フォーク
108
PR マージ指標
30日以内にマージされた PR はありません

説明

Hello,

I'm running into an issue where an attribute on my model that is set to a `fragmentArray` is always set to `null` by default rather than an empty array (default according to docs). I've tried setting in multiple ways, with no luck:

```js
customRates: fragmentArray('rate', { defaultValue: function() {
return [];
}}),
```

```js
customRates: fragmentArray('rate', { defaultValue: [] })
```

Here's the `rate` fragment I'm referencing:

```js
// rate.js
import attr from 'ember-data/attr';
import Fragment from 'model-fragments/fragment';
import { validator, buildValidations } from 'ember-cp-validations';

const Validations = buildValidations({
type: validator('presence', true),
amount: [
validator('presence', true),
validator('number', {
allowString: true,
gt: 0,
lte: 100
})
],
serviceType: validator('presence', true),
serviceId: validator('presence', true)
});

export default Fragment.extend(Validations, {
type: attr('string'),
amount: attr('number'),
serviceType: attr(),
serviceId: attr('number')
});
```

I'm running ED 2.11 and EDMF 2.11.

Thanks in advance!

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Start with the model declaration using fragmentArray and the rate.js fragment shown in the report, then trace how defaultValue is handled for fragment arrays. Reproduce the ED 2.11 and EDMF 2.11 behavior and verify that an unset customRates attribute becomes an empty array rather than null.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript
領域
backend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。