From 83d0e05bdc5ed1db545576a1729a27f1d39c8836 Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Tue, 14 Feb 2023 16:26:31 -0500 Subject: [PATCH] fix: handle cases where union type is already atom --- lib/ash/type/union.ex | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ash/type/union.ex b/lib/ash/type/union.ex index ac9c4d89..e39222be 100644 --- a/lib/ash/type/union.ex +++ b/lib/ash/type/union.ex @@ -254,7 +254,13 @@ defmodule Ash.Type.Union do def cast_stored(nil, _), do: {:ok, nil} def cast_stored(%{"type" => type, "value" => value}, constraints) do - type = String.to_existing_atom(type) + type = + if is_binary(type) do + String.to_existing_atom(type) + else + type + end + types = constraints[:types] || [] case Keyword.fetch(types, type) do