zskreisz
zskreisz
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
soft delete - identity issue
i have a resource, for which soft delete is on, the resource has a field: :deleted_at. If I do not add this field to the identity, on creation the data is validated to be unique, but if I (soft) delete a record, than I can not create another one with the same unique fields. If I add the field to the identity, on creation the data is not validated correctly, since it includes the deleted_at null field. I created a template project back then without ash for the soft delete and historization, and someone told me to add the nulls_distinct: false option, and it will solve the problem. I also found the same config option in ash, and added nils_distinct?: false. Now it looks good for checking uniqueness upon creation, and I can also delete a resource, but only once. Somehow the deleted_at uniqueness should be - according to my understanding - unique on the timestamp basis, but it still gives me this error upon save: Form Error: [ %Ash.Error.Changes.InvalidAttribute{ field: :deleted_at, message: "Supplier price already exists for this configuration", private_vars: [ constraint: :unique, constraint_name: "supplier_prices_unique_supplier_price_index" ], value: nil, splode: Ash.Error, bread_crumbs: [], vars: [], path: [], stacktrace: #splode.Stacktrace<>, class: :invalid }
4 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
Hi Guys! I am trying to apply a simple nested form, and I can not get through. The use-case is simple: I want to add supplier_prices to my users. I tried to do everything according to the docs, probably missed something. user.ex:
update :update_with_supplier_price do
require_atomic? false
argument :supplier_prices, {:array, :map}, allow_nil?: true

change manage_relationship(:supplier_prices,
type: :append_and_remove)
end
update :update_with_supplier_price do
require_atomic? false
argument :supplier_prices, {:array, :map}, allow_nil?: true

change manage_relationship(:supplier_prices,
type: :append_and_remove)
end
follow up in comment(s)(?).
51 replies