fix: reproduce issue around atomic updates & validations

This commit is contained in:
Zach Daniel 2024-04-22 18:58:57 -04:00
parent d26a189946
commit ec91e2ee9b
2 changed files with 17 additions and 0 deletions

View file

@ -33,6 +33,18 @@ defmodule AshPostgres.AtomicsTest do
|> Ash.update!()
end
test "an atomic validation is based on where it appears in the action" do
post =
Post
|> Ash.Changeset.for_create(:create, %{title: "bar"})
|> Ash.create!()
# just asserting that there is no exception here
post
|> Ash.Changeset.for_update(:change_title_to_foo_unless_its_already_foo)
|> Ash.update!()
end
test "an atomic works with a datetime" do
post =
Post

View file

@ -113,6 +113,11 @@ defmodule AshPostgres.Test.Post do
require_atomic?(false)
end
update :change_title_to_foo_unless_its_already_foo do
validate attribute_does_not_equal(:title, "foo")
change set_attribute(:title, "foo")
end
read :title_is_foo do
filter(expr(title == "foo"))
end