Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions test/atomics_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
defmodule AshPostgres.AtomicsTest do
alias AshPostgres.Test.Author
alias AshPostgres.Test.Comment
alias AshPostgres.Test.TempEntity

use AshPostgres.RepoCase, async: false

Expand Down Expand Up @@ -465,6 +466,16 @@
assert post.score == 20
end

test "atomic_set works on create with required attribute and fragment" do

Check failure on line 469 in test/atomics_test.exs

View workflow job for this annotation

GitHub Actions / ash-ci (15) / mix test

test atomic create (create_atomics) atomic_set works on create with required attribute and fragment (AshPostgres.AtomicsTest)

Check failure on line 469 in test/atomics_test.exs

View workflow job for this annotation

GitHub Actions / ash-ci (14) / mix test

test atomic create (create_atomics) atomic_set works on create with required attribute and fragment (AshPostgres.AtomicsTest)

Check failure on line 469 in test/atomics_test.exs

View workflow job for this annotation

GitHub Actions / ash-ci (16) / mix test

test atomic create (create_atomics) atomic_set works on create with required attribute and fragment (AshPostgres.AtomicsTest)
temp_entity =
TempEntity
|> Ash.Changeset.for_create(:create, %{})
|> Ash.Changeset.atomic_set(:full_name, expr(fragment("(SELECT 'name')")))
|> Ash.create!()

assert temp_entity.full_name == "name"
end

test "atomic_set on create overrides attributes when both are set" do
# If both attributes and atomic_set set a value, atomics should win
post =
Expand Down
Loading