mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 05:23:03 +12:00
fix: cast embedded datetimes properly
This commit is contained in:
parent
479b09951c
commit
d4a6feb589
3 changed files with 12 additions and 0 deletions
|
@ -26,6 +26,10 @@ defmodule Ash.Type.NaiveDatetime do
|
|||
@impl true
|
||||
def cast_stored(nil, _), do: {:ok, nil}
|
||||
|
||||
def cast_stored(value, constraints) when is_binary(value) do
|
||||
cast_input(value, constraints)
|
||||
end
|
||||
|
||||
def cast_stored(value, _) do
|
||||
Ecto.Type.load(:naive_datetime, value)
|
||||
end
|
||||
|
|
|
@ -24,6 +24,10 @@ defmodule Ash.Type.UtcDatetime do
|
|||
@impl true
|
||||
def cast_stored(nil, _), do: {:ok, nil}
|
||||
|
||||
def cast_stored(value, constraints) when is_binary(value) do
|
||||
cast_input(value, constraints)
|
||||
end
|
||||
|
||||
def cast_stored(value, _) do
|
||||
Ecto.Type.load(:utc_datetime, value)
|
||||
end
|
||||
|
|
|
@ -24,6 +24,10 @@ defmodule Ash.Type.UtcDatetimeUsec do
|
|||
@impl true
|
||||
def cast_stored(nil, _), do: {:ok, nil}
|
||||
|
||||
def cast_stored(value, constraints) when is_binary(value) do
|
||||
cast_input(value, constraints)
|
||||
end
|
||||
|
||||
def cast_stored(value, _) do
|
||||
case Ecto.Type.load(:utc_datetime_usec, value) do
|
||||
{:ok, value} ->
|
||||
|
|
Loading…
Reference in a new issue