ash-project/ash_admin

support for {:array, UnionType}

Closed this issue · 1 comments

Caveat
I believe this is ash_phoenix library fix rather than ash_admin

Describe the bug

Support {:array, Union}

To Reproduce

Make tickmet metadata as array:
revati@e1678a8#diff-c8a6a1598f51e1ee927e6577d8fc5b4895ad054ea71d7f886d88f2410261af81R175

Expected behavior

Work fine. :D

Runtime

  • Elixir version
  • Erlang version
  • OS
  • Ash version
  • any related extension versions

Additional context

Add any other context about the problem here.

There is also issue with union types being in nested schema.

[error] GenServer #PID<0.5947.0> terminating
** (RuntimeError) Got no "_union_type" parameter, and no union type had a tag & tag_value pair matching the params.

If you are adding a form, select a type using `params: %{"_union_type" => "type_name"}`, or if one
or more of your types is using a tag you can set that tag with `params: %{"tag" => "tag_value"}`.

Params:

%{"_new_union_type" => "integer", "value" => "1"}

Available types:

[
  integer: [type: :integer, tag: :type, tag_value: :integer],
  atom: [
    type: :atom,
    constraints: [one_of: [:result, :param, :state, :static]],
    tag: :type,
    tag_value: :atom
  ],
  string: [type: :string, tag: :type, tag_value: :string]
]

    (ash_phoenix 2.0.1) lib/ash_phoenix/form/auto.ex:287: AshPhoenix.Form.Auto.determine_type/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/auto.ex:156: anonymous fn/5 in AshPhoenix.Form.Auto.unions/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:3156: AshPhoenix.Form.update_opts/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1331: anonymous fn/7 in AshPhoenix.Form.validate_nested_forms/6
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1066: AshPhoenix.Form.validate/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1287: anonymous fn/9 in AshPhoenix.Form.validate_nested_forms/6
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1218: anonymous fn/7 in AshPhoenix.Form.validate_nested_forms/6
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1066: AshPhoenix.Form.validate/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1287: anonymous fn/9 in AshPhoenix.Form.validate_nested_forms/6
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1218: anonymous fn/7 in AshPhoenix.Form.validate_nested_forms/6
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1066: AshPhoenix.Form.validate/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1287: anonymous fn/9 in AshPhoenix.Form.validate_nested_forms/6
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1218: anonymous fn/7 in AshPhoenix.Form.validate_nested_forms/6
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3