mirror of
https://github.com/ash-project/ash.git
synced 2024-09-19 13:03:02 +12:00
fix: return proper data shape when doing a read in a transaction
closes #1410
This commit is contained in:
parent
3859571fae
commit
0007d0e60a
2 changed files with 11 additions and 1 deletions
|
@ -853,7 +853,7 @@ defmodule Ash.Actions.Read do
|
|||
|> case do
|
||||
{:error, {:error, error}} -> {:error, error}
|
||||
{:error, error} -> {:error, error}
|
||||
{:ok, result} -> {:ok, result}
|
||||
{:ok, result} -> result
|
||||
end
|
||||
|
||||
query.timeout ->
|
||||
|
|
|
@ -31,6 +31,10 @@ defmodule Ash.Test.Actions.ReadTest do
|
|||
actions do
|
||||
default_accept :*
|
||||
defaults [:read, :destroy, create: :*, update: :*]
|
||||
|
||||
read :in_transaction do
|
||||
transaction? true
|
||||
end
|
||||
end
|
||||
|
||||
attributes do
|
||||
|
@ -290,6 +294,12 @@ defmodule Ash.Test.Actions.ReadTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "transaction true" do
|
||||
test "with no records, returns an empty set" do
|
||||
assert [] = Ash.read!(Author, action: :in_transaction)
|
||||
end
|
||||
end
|
||||
|
||||
describe "Ash.read!/2 with no records" do
|
||||
test "returns an empty result" do
|
||||
assert [] = Ash.read!(Post)
|
||||
|
|
Loading…
Reference in a new issue