.. changelog::
:version: 0.8.7
+ .. change::
+ :tags: bug, sql
+ :versions: 1.0.0, 0.9.7
+ :tickets: 3102
+
+ Fixed a bug within the custom operator plus :meth:`.TypeEngine.with_variant`
+ system, whereby using a :class:`.TypeDecorator` in conjunction with
+ variant would fail with an MRO error when a comparison operator was used.
+
.. change::
:tags: bug, mysql
:versions: 1.0.0, 0.9.7
mapping[dialect_name] = type_
return Variant(self.impl, mapping)
+ @property
+ def comparator_factory(self):
+ """express comparison behavior in terms of the base type"""
+ return self.impl.comparator_factory
def to_instance(typeobj, *arg, **kw):
if typeobj is None:
class MyInteger(TypeDecorator):
impl = Integer
- class comparator_factory(TypeEngine.Comparator):
+ class comparator_factory(TypeDecorator.Comparator):
def __init__(self, expr):
self.expr = expr
return MyInteger
+class TypeDecoratorWVariantComparatorTest(_CustomComparatorTests, fixtures.TestBase):
+ def _add_override_factory(self):
+
+ class SomeOtherInteger(Integer):
+ class comparator_factory(TypeEngine.Comparator):
+ def __init__(self, expr):
+ self.expr = expr
+
+ def __add__(self, other):
+ return self.expr.op("not goofy")(other)
+
+ def __and__(self, other):
+ return self.expr.op("not goofy_and")(other)
+
+ class MyInteger(TypeDecorator):
+ impl = Integer
+
+ class comparator_factory(TypeDecorator.Comparator):
+ def __init__(self, expr):
+ self.expr = expr
+
+ def __add__(self, other):
+ return self.expr.op("goofy")(other)
+
+ def __and__(self, other):
+ return self.expr.op("goofy_and")(other)
+
+ return MyInteger().with_variant(SomeOtherInteger, "mysql")
+
class CustomEmbeddedinTypeDecoratorTest(_CustomComparatorTests, fixtures.TestBase):
def _add_override_factory(self):