From 93c375e9133ff784f1b6633b0f910ddb73a32afd Mon Sep 17 00:00:00 2001 From: James Harton Date: Thu, 2 Oct 2025 10:43:11 +1300 Subject: [PATCH] fix: weird typing issue with Postgres. This partially reverts the changes in 3cad640862c115a676ec806f77608b13c96ccf63. --- lib/expr.ex | 49 ++++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) 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