adopted-ember-addons / ember-changeset

Ember.js flavored changesets, inspired by Ecto
http://bit.ly/ember-changeset-demo
MIT License
431 stars 141 forks source link

Setting a relationship to `null` does not allow it to be set to any other value afterwards #643

Open javavick opened 2 years ago

javavick commented 2 years ago

Version

v3.15.0

Expected Behavior

When setting a relationship to null, you should then be able to set it back to another value.

Actual Behavior

When setting a relationship to null, you are not able to set its value to anything else and it remains set to null.

Steps to reproduce

this.changeset.relationship = this.store.peekRecord('relationship', id); // value is set to the found record.
this.changeset.relationship = null; // value is set to null.
this.changeset.relationship = this.store.peekRecord('relationship', id); // value continues to be set to null
dxmo commented 2 years ago

@fonsovariz I came across the same issue. Seems this has to do with some conditional logic inside 'validated-changeset'. Anyway I was able to workaround this by setting the value to 'undefined' instead of 'null'. See if that helps.

snewcomer commented 2 years ago

Seems like an easy PR if you want to take it!

dxmo commented 2 years ago

@snewcomer yup - let me give it a try ;)

dxmo commented 2 years ago

@snewcomer this pull request fixes it for me:

https://github.com/validated-changeset/validated-changeset/pull/163

dxmo commented 2 years ago

@snewcomer just a quick update - the issue disappeared the moment we upgraded our app to ember 3.28. I guess this issue can be closed

snewcomer commented 2 years ago

I'll leave it to @fonsovariz confirm. But missing null is a common bug. So I would assume there might be something other than an upgrade.

javavick commented 1 year ago

1 Year Later It works. 👍