fix: properly set source on attributes

This commit is contained in:
Zach Daniel 2022-10-05 20:25:18 -04:00
parent c591bf6746
commit 787cbad605
2 changed files with 5 additions and 1 deletions

View file

@ -201,6 +201,10 @@ defmodule Ash.Resource.Attribute do
|> OptionsHelpers.set_default!(:type, :integer) |> OptionsHelpers.set_default!(:type, :integer)
|> Keyword.delete(:allow_nil?) |> Keyword.delete(:allow_nil?)
def transform(attribute) do
Ash.Type.set_type_transformation(%{attribute | source: attribute.source || attribute.name})
end
@doc false @doc false
def attribute_schema, do: @schema def attribute_schema, do: @schema
def create_timestamp_schema, do: @create_timestamp_schema def create_timestamp_schema, do: @create_timestamp_schema

View file

@ -12,7 +12,7 @@ defmodule Ash.Resource.Dsl do
end end
""" """
], ],
transform: {Ash.Type, :set_type_transformation, []}, transform: {Ash.Resource.Attribute, :transform, []},
target: Ash.Resource.Attribute, target: Ash.Resource.Attribute,
args: [:name, :type], args: [:name, :type],
modules: [:type], modules: [:type],