fix: force_change attrs *after* for_create/update

This commit is contained in:
Zach Daniel 2021-03-15 15:55:26 -04:00
parent e60acf4167
commit 1b972b9598

View file

@ -714,6 +714,7 @@ defmodule Ash.Actions.ManagedRelationships do
relationship.through
|> Ash.Changeset.new()
|> Ash.Changeset.for_create(create_or_update, join_input)
|> Ash.Changeset.force_change_attribute(
relationship.source_field_on_join_table,
Map.get(record, relationship.source_field)
@ -722,7 +723,6 @@ defmodule Ash.Actions.ManagedRelationships do
relationship.destination_field_on_join_table,
Map.get(found, relationship.destination_field)
)
|> Ash.Changeset.for_create(create_or_update, join_input)
|> Ash.Changeset.set_context(join_relationship.context)
|> Ash.Changeset.set_tenant(changeset.tenant)
|> api.create(
@ -878,6 +878,7 @@ defmodule Ash.Actions.ManagedRelationships do
relationship.through
|> Ash.Changeset.new()
|> Ash.Changeset.for_create(join_action_name, join_params)
|> Ash.Changeset.force_change_attribute(
relationship.source_field_on_join_table,
Map.get(record, relationship.source_field)
@ -886,7 +887,6 @@ defmodule Ash.Actions.ManagedRelationships do
relationship.destination_field_on_join_table,
Map.get(created, relationship.destination_field)
)
|> Ash.Changeset.for_create(join_action_name, join_params)
|> Ash.Changeset.set_context(join_relationship.context)
|> Ash.Changeset.set_tenant(changeset.tenant)
|> changeset.api.create(