@@ -464,11 +464,10 @@ defmodule Ash.Type.Union do
464464 end
465465 end
466466
467- @ impl true
468- def load ( unions , [ ] , _ , _ ) , do: { :ok , unions }
469-
470467 @ impl true
471468 def load ( unions , load , constraints , context ) do
469+ load = load || [ ]
470+
472471 if Enum . any? ( constraints [ :types ] , fn { _name , config } ->
473472 Ash.Type . can_load? ( config [ :type ] , config [ :constraints ] )
474473 end ) do
@@ -1317,6 +1316,8 @@ defmodule Ash.Type.Union do
13171316 { :ok , type_config } <- Keyword . fetch ( type_configs , type_name ) ,
13181317 { :ok , type } <- Keyword . fetch ( type_config , :type ) ,
13191318 type_constraints <- Keyword . get ( type_config , :constraints , [ ] ) ,
1319+ type_constraints <-
1320+ Keyword . put ( type_constraints , :__union_tag__ , type_config [ :tag ] ) ,
13201321 type <- Ash.Type . get_type ( type ) ,
13211322 { :ok , value } <- Ash.Type . prepare_change ( type , old_value , new_value , type_constraints ) do
13221323 { :ok , % Ash.Union { type: type_name , value: value } }
@@ -1332,6 +1333,8 @@ defmodule Ash.Type.Union do
13321333 { :ok , type_config } <- Keyword . fetch ( type_configs , type_name ) ,
13331334 { :ok , type } <- Keyword . fetch ( type_config , :type ) ,
13341335 type_constraints <- Keyword . get ( type_config , :constraints , [ ] ) ,
1336+ type_constraints <-
1337+ Keyword . put ( type_constraints , :__union_tag__ , type_config [ :tag ] ) ,
13351338 type <- Ash.Type . get_type ( type ) ,
13361339 { :ok , value } <- Ash.Type . prepare_change ( type , nil , new_value , type_constraints ) do
13371340 { :ok , % Ash.Union { type: type_name , value: value } }
0 commit comments