Skip to content

Commit b056b1b

Browse files
authored
add regression tests for affording setting required attributes via atomic_set (#684)
1 parent 556ceb4 commit b056b1b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/atomics_test.exs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
defmodule AshPostgres.AtomicsTest do
66
alias AshPostgres.Test.Author
77
alias AshPostgres.Test.Comment
8+
alias AshPostgres.Test.TempEntity
89

910
use AshPostgres.RepoCase, async: false
1011

@@ -465,6 +466,16 @@ defmodule AshPostgres.AtomicsTest do
465466
assert post.score == 20
466467
end
467468

469+
test "atomic_set works on create with required attribute and fragment" do
470+
temp_entity =
471+
TempEntity
472+
|> Ash.Changeset.for_create(:create, %{})
473+
|> Ash.Changeset.atomic_set(:full_name, expr(fragment("(SELECT 'name')")))
474+
|> Ash.create!()
475+
476+
assert temp_entity.full_name == "name"
477+
end
478+
468479
test "atomic_set on create overrides attributes when both are set" do
469480
# If both attributes and atomic_set set a value, atomics should win
470481
post =

0 commit comments

Comments
 (0)