From 01215cdaef4579b5d0806abd060a2dd90acabf9b Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 27 Jun 2014 16:08:42 -0400 Subject: - 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. fixes #3102 --- test/sql/test_operators.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'test/sql') diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py index 1006dc33a..9b6b2297f 100644 --- a/test/sql/test_operators.py +++ b/test/sql/test_operators.py @@ -355,7 +355,7 @@ class TypeDecoratorComparatorTest(_CustomComparatorTests, fixtures.TestBase): class MyInteger(TypeDecorator): impl = Integer - class comparator_factory(TypeEngine.Comparator): + class comparator_factory(TypeDecorator.Comparator): def __init__(self, expr): self.expr = expr @@ -368,6 +368,35 @@ class TypeDecoratorComparatorTest(_CustomComparatorTests, fixtures.TestBase): 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): -- cgit v1.2.1