Skip to content

Commit

Permalink
chore: handle ci_string type as storage type
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Oct 10, 2023
1 parent 9f62d65 commit f67db5e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
18 changes: 17 additions & 1 deletion lib/types/types.ex
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,28 @@ defmodule AshPostgres.Types do
end

if cast_in_query? do
parameterized_type(Ash.Type.ecto_type(type), constraints)
type = Ash.Type.ecto_type(type)

type =
if type.type(constraints) == :ci_string do
Ash.Type.CiStringWrapper
else
type
end

parameterized_type(type, constraints)
else
nil
end
else
if is_atom(type) && :erlang.function_exported(type, :type, 1) do
type =
if type == :ci_string do
:citext
else
type
end

{:parameterized, type, constraints || []}
else
type
Expand Down
7 changes: 3 additions & 4 deletions test/aggregate_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,9 @@ defmodule AshPostgres.AggregateTest do
|> Ash.Changeset.new(%{title: "title"})
|> Api.create!()

post2 =
Post
|> Ash.Changeset.new(%{title: "title2"})
|> Api.create!()
Post
|> Ash.Changeset.new(%{title: "title2"})
|> Api.create!()

refute Post
|> Ash.Query.filter(has_comment_called_match)
Expand Down

0 comments on commit f67db5e

Please sign in to comment.