fix: add __source__ to union inner_constraints (#1160)

This commit is contained in:
Barnabas Jovanovics 2024-05-13 18:45:31 +02:00 committed by GitHub
parent 3e27ca9df5
commit de0bd815e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -365,7 +365,14 @@ defmodule Ash.Type.Union do
inner_constraints = inner_constraints =
if Ash.Type.embedded_type?(type) do if Ash.Type.embedded_type?(type) do
Keyword.put(inner_constraints, :__union_tag__, constraints[:types][type_name][:tag]) case constraints[:__source__] do
%Ash.Changeset{} = source ->
Keyword.put(inner_constraints, :__source__, source)
_ ->
inner_constraints
end
|> Keyword.put(:__union_tag__, constraints[:types][type_name][:tag])
else else
inner_constraints inner_constraints
end end