summaryrefslogtreecommitdiff
path: root/test/dialect
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-02-02 10:15:40 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2016-02-02 10:20:54 -0500
commite0a580b3d055a600afae61840058a5a30ef5fe74 (patch)
tree592356800f2b452028bae1f91ffcffad8157aa87 /test/dialect
parentc8b3d4ed3f2638599fc73486cf0f724fa033a638 (diff)
downloadsqlalchemy-e0a580b3d055a600afae61840058a5a30ef5fe74.tar.gz
- Fixed issue where inadvertent use of the Python ``__contains__``
override with a column expression (e.g. by using ``'x' in col``) would cause an endless loop in the case of an ARRAY type, as Python defers this to ``__getitem__`` access which never raises for this type. Overall, all use of ``__contains__`` now raises NotImplementedError. fixes #3642
Diffstat (limited to 'test/dialect')
-rw-r--r--test/dialect/postgresql/test_types.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py
index 50b66f290..c53c67cef 100644
--- a/test/dialect/postgresql/test_types.py
+++ b/test/dialect/postgresql/test_types.py
@@ -772,6 +772,15 @@ class ArrayTest(AssertsCompiledSQL, fixtures.TestBase):
checkparams={'param_1': 4, 'param_3': 6, 'param_2': 5}
)
+ def test_contains_override_raises(self):
+ col = column('x', postgresql.ARRAY(Integer))
+
+ assert_raises_message(
+ NotImplementedError,
+ "Operator 'contains' is not supported on this expression",
+ lambda: 'foo' in col
+ )
+
def test_array_contained_by(self):
col = column('x', postgresql.ARRAY(Integer))
self.assert_compile(