From 6d7d48af0dec6325f87ce497f769827107ad5035 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 1 Apr 2017 11:36:16 -0400 Subject: Return self when Variant.coerce_compared_value would return impl Fixed regression released in 1.1.5 due to :ticket:`3859` where adjustments to the "right-hand-side" evaluation of an expression based on :class:`.Variant` to honor the underlying type's "right-hand-side" rules caused the :class:`.Variant` type to be inappropriately lost, in those cases when we *do* want the left-hand side type to be transferred directly to the right hand side so that bind-level rules can be applied to the expression's argument. Change-Id: Ia54dbbb19398549d654b74668753c4152599d900 Fixes: #3952 --- lib/sqlalchemy/sql/type_api.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/type_api.py b/lib/sqlalchemy/sql/type_api.py index d537e49f0..4b561a705 100644 --- a/lib/sqlalchemy/sql/type_api.py +++ b/lib/sqlalchemy/sql/type_api.py @@ -1214,7 +1214,11 @@ class Variant(TypeDecorator): self.mapping = mapping def coerce_compared_value(self, operator, value): - return self.impl.coerce_compared_value(operator, value) + result = self.impl.coerce_compared_value(operator, value) + if result is self.impl: + return self + else: + return result def load_dialect_impl(self, dialect): if dialect.name in self.mapping: -- cgit v1.2.1