dwyl / alog

🌲 alog (Append-only Log) is an easy way to start using the Lambda/Kappa architecture in your Elixir/Phoenix Apps while still using PostgreSQL (with Ecto).
GNU General Public License v2.0
15 stars 2 forks source link

Adding entry_ids to assocs built with `cast_assoc` #22

Open Danwhy opened 5 years ago

Danwhy commented 5 years ago

If we apply the cast_assoc function to a changeset, the association is added to the changes, and will be inserted into the database if it doesn't exist.

This can cause a problem for us, as the association will be inserted without an entry id.

To fix this, when adding the entry_id on the insert function, we should iterate through the changes, checking if there are any nested changesets, and add entry_ids to those too.