From de0bd815e8cb3ad168ebef777bd62ec7e5fde17c Mon Sep 17 00:00:00 2001 From: Barnabas Jovanovics Date: Mon, 13 May 2024 18:45:31 +0200 Subject: [PATCH] fix: add __source__ to union inner_constraints (#1160) --- lib/ash/type/union.ex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/ash/type/union.ex b/lib/ash/type/union.ex index ab22de1c..b5c18c9b 100644 --- a/lib/ash/type/union.ex +++ b/lib/ash/type/union.ex @@ -365,7 +365,14 @@ defmodule Ash.Type.Union do inner_constraints = 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 inner_constraints end