When I run the following code, the subtask_id ends up being different from what was specified in the “new_task” map. How do I make it persist the predefine ID?
subtask_id = Ash.UUID.generate() ## let's say this is '1234-xxx'
new_task =
%{
task_name: "Parent resource",
subtasks: [
%{
id: subtask_id,
subtask_name: "nested resource"
}]
}
Task
|> Ash.Changeset.for_create(:create, new_task)
|> Tasks.create!() ### the actual subtask_id persisted is different from "1234-xxx"
In case it matters, the create action of Task includes the following,
argument :subtasks, {:array, :map}
change manage_relationship(:subtasks, type: :create)
and the attributes
section of Subtask includes
attributes do
uuid_primary_key(:id)