mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-19 21:13:19 +12:00
fix: use CiStringWrapper
type in ash_postgres
This commit is contained in:
parent
ee7dd56710
commit
912fab9a96
3 changed files with 22 additions and 0 deletions
|
@ -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)
|
||||
|
|
14
lib/types/ci_string_wrapper.ex
Normal file
14
lib/types/ci_string_wrapper.ex
Normal 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
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue