adopted-ember-addons / adopted-ember-addons/validated-changeset

Snapshot changes is wrong when object has proxy attributes

未关闭
#102 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
TypeScript
星标
38
派生
27
PR 合并指标
30 天内没有已合并 PR

描述

Hi, changeset of ED Models with async belongsTo relationships show incorrect changes on snapshot:
![Screenshot 2021-02-03 at 16 15 37](https://user-images.githubusercontent.com/50884/106775512-1799ef80-663b-11eb-8145-fa68de987259.png)

`change` and `changes` are correct, but `snapshot().changes` shows all my async belongsTo as changed attributes incorrectly.

I think this is because of this unrwrap https://github.com/validated-changeset/validated-changeset/blob/da68651a41028ab827872cf10960920779c2a09f/src/index.ts#L975

Which adds all the unwrapped relationships to `this[CHANGES]`. When i get `change` and `changes` these incorrect changes are filtered out, but not on snapshot.

Does my explanation make sense? Thanks in advance!

EDIT:
If anyone else comes here looking for a solution I'm currently creating snapshots like this until it is fixed
```js
function createSnapshot(cs) {
const changes = {};
cs.changes.forEach(({ key, value }) => { changes[key] = value; });
return {
changes,
errors: { ...cs.error },
};
}
```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。