mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 05:23:03 +12:00
chore: release version v1.50.17
This commit is contained in:
parent
c4c2c133c7
commit
9143cf2359
4 changed files with 14 additions and 39 deletions
|
@ -5,6 +5,15 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
|
|||
|
||||
<!-- changelog -->
|
||||
|
||||
## [v1.50.17](https://github.com/ash-project/ash/compare/v1.50.16...v1.50.17) (2022-01-31)
|
||||
|
||||
|
||||
|
||||
|
||||
### Improvements:
|
||||
|
||||
* optimize `if` and `is_nil` functions
|
||||
|
||||
## [v1.50.16](https://github.com/ash-project/ash/compare/v1.50.15...v1.50.16) (2022-01-24)
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ defmodule Ash.Query.Function.Ago do
|
|||
"""
|
||||
use Ash.Query.Function, name: :ago
|
||||
|
||||
def args, do: [[:integer, Ash.Type.Interval]]
|
||||
def args, do: [[:integer, :interval]]
|
||||
|
||||
def evaluate(%{arguments: [factor, interval]}) do
|
||||
interval =
|
||||
|
|
|
@ -1,43 +1,9 @@
|
|||
defmodule Ash.Type.Interval do
|
||||
@intervals ~w(year month week day hour minute second millisecond microsecond)a
|
||||
@string_intervals Enum.map(@intervals, &to_string/1)
|
||||
@string_intervals_to_interval Enum.map(@intervals, &{&1, to_string(&1)})
|
||||
@values ~w(year month week day hour minute second millisecond microsecond)a
|
||||
@moduledoc """
|
||||
An interval of time, primarily meant to be used in expression functions
|
||||
|
||||
Valid intervals are (as strings or atoms): #{inspect(@intervals)}
|
||||
Valid intervals are (as strings or atoms): #{inspect(@values)}
|
||||
"""
|
||||
use Ash.Type
|
||||
|
||||
@impl true
|
||||
def storage_type, do: :string
|
||||
|
||||
@impl true
|
||||
def cast_input(value, _) when value in @intervals do
|
||||
{:ok, value}
|
||||
end
|
||||
|
||||
def cast_input(value, _) when value in @string_intervals do
|
||||
{:ok, @string_intervals_to_interval[value]}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def cast_stored(nil, _), do: {:ok, nil}
|
||||
|
||||
def cast_stored(value, _) when value in @intervals do
|
||||
{:ok, value}
|
||||
end
|
||||
|
||||
def cast_stored(value, _) when value in @string_intervals do
|
||||
{:ok, @string_intervals_to_interval[value]}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def dump_to_native(nil, _), do: {:ok, nil}
|
||||
|
||||
def dump_to_native(value, _) when is_atom(value) do
|
||||
{:ok, to_string(value)}
|
||||
end
|
||||
|
||||
def dump_to_native(_, _), do: :error
|
||||
use Ash.Type.Enum, values: @values
|
||||
end
|
||||
|
|
2
mix.exs
2
mix.exs
|
@ -7,7 +7,7 @@ defmodule Ash.MixProject do
|
|||
designed to be used by multiple front ends.
|
||||
"""
|
||||
|
||||
@version "1.50.16"
|
||||
@version "1.50.17"
|
||||
|
||||
def project do
|
||||
[
|
||||
|
|
Loading…
Reference in a new issue