dwyl / smart-home-auth-server

The authorisation server for dwyl/smart-home-security-system
GNU General Public License v2.0
5 stars 1 forks source link

Attempting to PUT lock data without User relations raises #11

Open th0mas opened 3 years ago

th0mas commented 3 years ago

When sending a PUT request editing a lock, it raises an error if existing user relations are not included,

you are attempting to change relation :users of SmartHomeAuth.Access.Door but the :on_replace option of this relation is set to :raise.

By default it is not possible to replace or delete embeds and associations during cast. Therefore Ecto requires all existing data to be given on update. Failing to do so results in this error message.

If you want to replace data or automatically delete any data not sent to cast, please set the appropriate :on_replace option when defining the relation. The docs for Ecto.Changeset covers the supported options in the "Associations, embeds and on replace" section.

However, if you don't want to allow data to be replaced or deleted, only updated, make sure that:

  • If you are attempting to update an existing entry, you are including the entry primary key (ID) in the data.

  • If you have a relationship with many children, at least the same N children must be given on update.