Hi, I’ve been trying to implement optimistic locking on a simple resource using a global changes block:
changes do
change optimistic_lock(:lock_version), on: [:update, :destroy]
end
However, when I try to destroy a stale record via Ash.destroy(), I get an :ok result instead of a StaleRecord error, even though the record is not destroyed in the database. (I noticed that the ash test cases only cover the :update case, but not the :destroy case …)
A related question: The HowTo “Add Optimistic Locking” has an optimistic_lock also on :create. Why? A newly created record can’t be stale, can it?