Precondition checks and atomic
I often have to check the current value of a resource object in the DB as part of precondition checks of an action (e.g. when updating a "status" column I have to make sure it has a specific value before doing it).
At first I tried to use "validation" for this but that seems to be only for input arguments and input attributes.
So instead I used "change before_action" hooks to load the existing record and add an error to the Changeset if needed.
This works but Ash is complaining that it cannot run it as "atomic" so it needs "require_atomic? false".
I find this a bit confusing as the docs on changeset hooks imply that "before_action" is run within the transaction.
Am I wrong to assume that "atomic" and "transactional" are the same thing in Ash? Is "before_action" executed outside the DB transaction?
I couldn't find a clear answer how to do this properly (as in idiomatic Ash and it being transactional)
At first I tried to use "validation" for this but that seems to be only for input arguments and input attributes.
So instead I used "change before_action" hooks to load the existing record and add an error to the Changeset if needed.
This works but Ash is complaining that it cannot run it as "atomic" so it needs "require_atomic? false".
I find this a bit confusing as the docs on changeset hooks imply that "before_action" is run within the transaction.
Am I wrong to assume that "atomic" and "transactional" are the same thing in Ash? Is "before_action" executed outside the DB transaction?
I couldn't find a clear answer how to do this properly (as in idiomatic Ash and it being transactional)
