improvement: handle non-cast-in-type queries

This commit is contained in:
Zach Daniel 2023-08-14 12:42:01 -07:00
parent de2817dfa1
commit c570d5f60e
2 changed files with 11 additions and 2 deletions

View file

@ -59,7 +59,12 @@ defmodule AshPostgres.Calculation do
type
)
expr = Ecto.Query.dynamic(type(^expr, ^type))
expr =
if type do
Ecto.Query.dynamic(type(^expr, ^type))
else
expr
end
{calculation.load, calculation.name, expr}
end)

View file

@ -964,7 +964,11 @@ defmodule AshPostgres.Expr do
arg1 = maybe_uuid_to_binary(arg2, arg1, arg1)
type = AshPostgres.Types.parameterized_type(arg2, constraints)
if type do
Ecto.Query.dynamic(type(^do_dynamic_expr(query, arg1, bindings, embedded?, type), ^type))
else
do_dynamic_expr(query, arg1, bindings, embedded?, type)
end
end
defp do_dynamic_expr(