Ash.Type.NewType: A type defined as subtype_of: :ci_string leads to postgres error in read actions. Attribute is cast as ::ci_string instead of ::citext #375
and using the new type as the type of an attribute leads to postgres error in read actions
Postgres casts the attribute as ::ci_string instead of ::citext
Used for an action argument it is cast correctly as ::citext
To Reproduce
defmodule MyApp.Types.Prefix do
use Ash.Type.NewType,
subtype_of: :ci_string,
constraints: [casing: :upper]
end
defmodule MyApp.Orgs.Org do
...
attributes do
...
attribute :prefix, MyApp.Types.Prefix, allow_nil?: false
end
actions do
read :by_prefix do
argument :prefix, MyApp.Types.Prefix
filter(expr(prefix==^arg(:prefix)))
end
end
Calling MyApp.Orgs.Org.by_prefix("ABCD") gives posgres error:
%Ash.Error.Unknown.UnknownError{
error: "** (Postgrex.Error) ERROR 42704 (undefined_object)
type \"ci_string\" does not exist\n\n
query: SELECT o0.\"id\", o0.\"prefix\" FROM \"orgs\" AS o0 WHERE (o0.\"prefix\"::ci_string = ($1::citext))",
Describe the bug Defining a new type with
and using the new type as the type of an attribute leads to postgres error in read actions Postgres casts the attribute as ::ci_string instead of ::citext
Used for an action argument it is cast correctly as ::citext
To Reproduce
Runtime