From 5d85c5be14fcb5799553f49588cf0cd0cba2b272 Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Tue, 17 Oct 2023 13:39:21 -0400 Subject: [PATCH] improvement: properly honor ecto type `init` callback --- lib/ash/type/datetime.ex | 4 +++- lib/ash/type/type.ex | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/ash/type/datetime.ex b/lib/ash/type/datetime.ex index 46dc8e2d6..8b09d5310 100644 --- a/lib/ash/type/datetime.ex +++ b/lib/ash/type/datetime.ex @@ -38,7 +38,9 @@ defmodule Ash.Type.DateTime do storage_type end - def storage_type(_), do: :utc_datetime + def storage_type(_constraints) do + :utc_datetime + end @impl true def generator(_constraints) do diff --git a/lib/ash/type/type.ex b/lib/ash/type/type.ex index 39d7af87c..884b39847 100644 --- a/lib/ash/type/type.ex +++ b/lib/ash/type/type.ex @@ -949,9 +949,12 @@ defmodule Ash.Type do def init(opts) do constraints = @parent.constraints() + {:ok, opts} = + opts + |> Keyword.take(Keyword.keys(constraints)) + |> @parent.init() + opts - |> Keyword.take(Keyword.keys(constraints)) - |> @parent.init() end @impl true