diff --git a/lib/expr.ex b/lib/expr.ex index 28548a3..b298567 100644 --- a/lib/expr.ex +++ b/lib/expr.ex @@ -3490,35 +3490,30 @@ defmodule AshSql.Expr do end defp maybe_type_expr(query, expr, bindings, embedded?, acc, type) do - cond do - type && get_path_array_type?(type) -> - case strip_get_path_type(expr) do - %GetPath{} = get_path -> - get_untyped_get_path_expr(query, get_path, bindings, embedded?, acc) - - _ -> - do_dynamic_expr(query, expr, bindings, embedded?, acc, type) - end - - type -> - {type, constraints} = - case type do - {:array, type} -> {{:array, type}, []} - {type, constraints} -> {type, constraints} - type -> {type, []} - end + if type do + case strip_get_path_type(expr) do + %GetPath{} = get_path -> + get_untyped_get_path_expr(query, get_path, bindings, embedded?, acc) - do_dynamic_expr( - query, - %Ash.Query.Function.Type{arguments: [expr, type, constraints]}, - bindings, - embedded?, - acc, - type - ) + _ -> + {type, constraints} = + case type do + {:array, type} -> {{:array, type}, []} + {type, constraints} -> {type, constraints} + type -> {type, []} + end - true -> - do_dynamic_expr(query, expr, bindings, embedded?, acc, type) + do_dynamic_expr( + query, + %Ash.Query.Function.Type{arguments: [expr, type, constraints]}, + bindings, + embedded?, + acc, + type + ) + end + else + do_dynamic_expr(query, expr, bindings, embedded?, acc, type) end end