fix: use CiStringWrapper type in ash_postgres

This commit is contained in:
Zach Daniel 2021-12-17 13:25:14 -05:00
parent ee7dd56710
commit 912fab9a96
3 changed files with 22 additions and 0 deletions

View file

@ -1601,6 +1601,10 @@ defmodule AshPostgres.DataLayer do
{:array, parameterized_type(type, constraints[:items] || [])}
end
defp parameterized_type(Ash.Type.CiString, constraints) do
parameterized_type(Ash.Type.CiStringWrapper, constraints)
end
defp parameterized_type(type, constraints) do
if Ash.Type.ash_type?(type) do
parameterized_type(Ash.Type.ecto_type(type), constraints)

View file

@ -0,0 +1,14 @@
defmodule Ash.Type.CiStringWrapper do
@moduledoc false
use Ash.Type
@impl true
def storage_type, do: :citext
@impl true
defdelegate cast_input(value, constraints), to: Ash.Type.CiString
@impl true
defdelegate cast_stored(value, constraints), to: Ash.Type.CiString
@impl true
defdelegate dump_to_native(value, constraints), to: Ash.Type.CiString
end

View file

@ -30,6 +30,10 @@ defmodule AshPostgres.Test.Comment do
create_timestamp(:created_at)
end
aggregates do
first(:post_category, :post, :category)
end
relationships do
belongs_to(:post, AshPostgres.Test.Post)
belongs_to(:author, AshPostgres.Test.Author)