Bulk create action Changeset Error
I'm using bulk create action with upsert and I'm tryong to test that not valid resources will not be created.
Using this code with a purposedly wrong changeset gives me this error:
I would expect errors to be "nilled"
resources =
input.resources_attributes
|> MmsBiztalk.bulk_create!(
input.resource,
:create,
upsert?: true,
upsert_identity: :unique_esolver_id,
# for bulk actions upsert_fields must be specified
upsert_fields: hd(input.resources_attributes) |> Map.keys(),
return_stream?: false,
return_records?: true
)
|> Stream.map(fn
{:ok, created_resource} ->
created_resource |> input.resource.to_status!([:syncing, :synced])
_ ->
nil
end)
|> Enum.to_list() resources =
input.resources_attributes
|> MmsBiztalk.bulk_create!(
input.resource,
:create,
upsert?: true,
upsert_identity: :unique_esolver_id,
# for bulk actions upsert_fields must be specified
upsert_fields: hd(input.resources_attributes) |> Map.keys(),
return_stream?: false,
return_records?: true
)
|> Stream.map(fn
{:ok, created_resource} ->
created_resource |> input.resource.to_status!([:syncing, :synced])
_ ->
nil
end)
|> Enum.to_list()Using this code with a purposedly wrong changeset gives me this error:
** (FunctionClauseError) no function clause matching in anonymous fn/2 in Ash.Actions.Create.Bulk.do_run/5
(ash 2.9.10) anonymous fn(#Ash.Changeset<api: MmsBiztalk, action_type: :create, action: :create, attributes: %{...}, errors: [%Ash.Error.Changes.Required{field: :customer_id, type: :argument, resource: MmsBiztalk.InvoiceData, changeset: nil, query: nil, error_context: [], vars: [], path: [], stacktrace: #Stacktrace<>, class: :invalid}], data: #MmsBiztalk.InvoiceData<customer: #Ash.NotLoaded<:relationship>, data_in: #Ash.NotLoaded<:relationship>, __meta__: #Ecto.Schema.Metadata<:built, ...>, context: %{bulk_create: %{index: 0}}, valid?: false>, %{batch: [], count: 0, must_return_records?: false}) in Ash.Actions.Create.Bulk.do_run/5 ** (FunctionClauseError) no function clause matching in anonymous fn/2 in Ash.Actions.Create.Bulk.do_run/5
(ash 2.9.10) anonymous fn(#Ash.Changeset<api: MmsBiztalk, action_type: :create, action: :create, attributes: %{...}, errors: [%Ash.Error.Changes.Required{field: :customer_id, type: :argument, resource: MmsBiztalk.InvoiceData, changeset: nil, query: nil, error_context: [], vars: [], path: [], stacktrace: #Stacktrace<>, class: :invalid}], data: #MmsBiztalk.InvoiceData<customer: #Ash.NotLoaded<:relationship>, data_in: #Ash.NotLoaded<:relationship>, __meta__: #Ecto.Schema.Metadata<:built, ...>, context: %{bulk_create: %{index: 0}}, valid?: false>, %{batch: [], count: 0, must_return_records?: false}) in Ash.Actions.Create.Bulk.do_run/5I would expect errors to be "nilled"
