mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 13:33:20 +12:00
fix: errors on casting arrays of unions in newtypes
This commit is contained in:
parent
805323f239
commit
687723730a
3 changed files with 11 additions and 13 deletions
|
@ -14,7 +14,6 @@ defmodule Ash.Error.Invalid.Unavailable do
|
||||||
|
|
||||||
def code(_), do: "unavailable"
|
def code(_), do: "unavailable"
|
||||||
|
|
||||||
@spec message(%Ash.Error.Invalid.Unavailable{}) :: <<_::64, _::_*8>>
|
|
||||||
def message(%{resource: resource, source: source, reason: reason}) when not is_nil(source) do
|
def message(%{resource: resource, source: source, reason: reason}) when not is_nil(source) do
|
||||||
"""
|
"""
|
||||||
#{inspect(resource)} - the resource is not available#{with_reason(reason)}.
|
#{inspect(resource)} - the resource is not available#{with_reason(reason)}.
|
||||||
|
|
|
@ -175,23 +175,26 @@ defmodule Ash.Schema do
|
||||||
:ok
|
:ok
|
||||||
|
|
||||||
%{type: :belongs_to} ->
|
%{type: :belongs_to} ->
|
||||||
belongs_to relationship.name, relationship.destination,
|
belongs_to(relationship.name, relationship.destination,
|
||||||
define_field: false,
|
define_field: false,
|
||||||
references: relationship.destination_attribute,
|
references: relationship.destination_attribute,
|
||||||
foreign_key: relationship.source_attribute
|
foreign_key: relationship.source_attribute
|
||||||
|
)
|
||||||
|
|
||||||
%{type: :has_many} ->
|
%{type: :has_many} ->
|
||||||
has_many relationship.name, relationship.destination,
|
has_many(relationship.name, relationship.destination,
|
||||||
foreign_key: relationship.destination_attribute,
|
foreign_key: relationship.destination_attribute,
|
||||||
references: relationship.source_attribute
|
references: relationship.source_attribute
|
||||||
|
)
|
||||||
|
|
||||||
%{type: :has_one} ->
|
%{type: :has_one} ->
|
||||||
has_one relationship.name, relationship.destination,
|
has_one(relationship.name, relationship.destination,
|
||||||
foreign_key: relationship.destination_attribute,
|
foreign_key: relationship.destination_attribute,
|
||||||
references: relationship.source_attribute
|
references: relationship.source_attribute
|
||||||
|
)
|
||||||
|
|
||||||
%{type: :many_to_many} ->
|
%{type: :many_to_many} ->
|
||||||
many_to_many relationship.name, relationship.destination,
|
many_to_many(relationship.name, relationship.destination,
|
||||||
join_through: relationship.through,
|
join_through: relationship.through,
|
||||||
join_keys: [
|
join_keys: [
|
||||||
{relationship.source_attribute_on_join_resource,
|
{relationship.source_attribute_on_join_resource,
|
||||||
|
@ -199,6 +202,7 @@ defmodule Ash.Schema do
|
||||||
{relationship.destination_attribute_on_join_resource,
|
{relationship.destination_attribute_on_join_resource,
|
||||||
relationship.destination_attribute}
|
relationship.destination_attribute}
|
||||||
]
|
]
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
Module.put_attribute(
|
Module.put_attribute(
|
||||||
|
|
|
@ -178,10 +178,10 @@ defmodule Ash.Type.NewType do
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl Ash.Type
|
@impl Ash.Type
|
||||||
def equal?(value, constraints) do
|
def equal?(left, right) do
|
||||||
unquote(subtype_of).equal?(
|
unquote(subtype_of).equal?(
|
||||||
value,
|
left,
|
||||||
type_constraints(constraints, unquote(subtype_constraints))
|
right
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -248,11 +248,6 @@ defmodule Ash.Type.NewType do
|
||||||
unquote(subtype_of).storage_type()
|
unquote(subtype_of).storage_type()
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl Ash.Type
|
|
||||||
def ecto_type do
|
|
||||||
unquote(subtype_of).ecto_type()
|
|
||||||
end
|
|
||||||
|
|
||||||
@impl Ash.Type
|
@impl Ash.Type
|
||||||
def constraints do
|
def constraints do
|
||||||
unquote(subtype_of).constraints()
|
unquote(subtype_of).constraints()
|
||||||
|
|
Loading…
Reference in a new issue