`on_match: :error` should error on unique key violation?
Hi, I want to make an invitation accept action, invitation has a relationship
member
which is a belongs_to from Member, it has user_id, entity_id, which is a unique pair, I want to make accept create a :member relationship, so if a user accepts an invitation that is already in entity, it will throw unique identity violation
This is what I have
4 Replies
have you looked at the relationships guide? There is a section on
manage_relationship
. Did an LLM give you that change relation
code?
That isn't a function
https://hexdocs.pm/ash/relationships.html#using-change-manage_relationship-3-in-actions
https://hexdocs.pm/ash/Ash.Changeset.html#manage_relationship/4Yes I have looked into that. I have created a function that returns my change module, which only calls manage_relationship with the same values as I passed them
I just want to know if I pass
on_match: :error
to Changeset.manage_relationship, shouldn't it error out if it finds a record matching the identity?It should yes. Did you try it?
use_identities: [:identity_name]
oh. I thought it is an array that accepts attributes
will try
thanks