fix: return proper data shape when doing a read in a transaction

closes #1410
This commit is contained in:
Zach Daniel 2024-08-30 15:18:56 -04:00
parent 3859571fae
commit 0007d0e60a
2 changed files with 11 additions and 1 deletions

View file

@ -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 ->

View file

@ -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)