From 889cbe53121c8fd50c845357dd52b24594346b68 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 1 May 2022 12:28:36 -0400 Subject: use bindparam_type in BinaryElementImpl._post_coercion if available Fixed an issue where using :func:`.bindparam` with no explicit data or type given could be coerced into the incorrect type when used in expressions such as when using :meth:`.ARRAY.comparator.any` and :meth:`.ARRAY.comparator.all`. Fixes: #7979 Change-Id: If7779e713c9a3a5fee496b66e417cfd3fca5b1f9 --- lib/sqlalchemy/sql/coercions.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/sql/coercions.py') diff --git a/lib/sqlalchemy/sql/coercions.py b/lib/sqlalchemy/sql/coercions.py index 2cf67abed..eef5cf211 100644 --- a/lib/sqlalchemy/sql/coercions.py +++ b/lib/sqlalchemy/sql/coercions.py @@ -759,9 +759,11 @@ class BinaryElementImpl(ExpressionElementImpl, RoleImpl): except exc.ArgumentError as err: self._raise_for_expected(element, err=err) - def _post_coercion(self, resolved, expr, **kw): + def _post_coercion(self, resolved, expr, bindparam_type=None, **kw): if resolved.type._isnull and not expr.type._isnull: - resolved = resolved._with_binary_element_type(expr.type) + resolved = resolved._with_binary_element_type( + bindparam_type if bindparam_type is not None else expr.type + ) return resolved -- cgit v1.2.1