summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-05-01 12:28:36 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2022-05-01 12:28:36 -0400
commit889cbe53121c8fd50c845357dd52b24594346b68 (patch)
treeeedc2ff066254e9f8f6ab88c62d36fc128f5f9da /lib/sqlalchemy/sql
parent724d33f3816b1460e8c89e73688235a3e31d8445 (diff)
downloadsqlalchemy-889cbe53121c8fd50c845357dd52b24594346b68.tar.gz
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
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/coercions.py6
1 files changed, 4 insertions, 2 deletions
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