summaryrefslogtreecommitdiff
path: root/test/sql/test_operators.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-06-27 16:08:42 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-06-27 16:08:42 -0400
commit01215cdaef4579b5d0806abd060a2dd90acabf9b (patch)
tree11fecd63452d91e8eae8c95c5e64a7db6b5e8102 /test/sql/test_operators.py
parent3d7cd1741b02d5c0e2ca08d7437759cda7c2a9be (diff)
downloadsqlalchemy-01215cdaef4579b5d0806abd060a2dd90acabf9b.tar.gz
- 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
Diffstat (limited to 'test/sql/test_operators.py')
-rw-r--r--test/sql/test_operators.py31
1 files changed, 30 insertions, 1 deletions
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):