summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/operators.py
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 /lib/sqlalchemy/sql/operators.py
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 'lib/sqlalchemy/sql/operators.py')
-rw-r--r--lib/sqlalchemy/sql/operators.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/operators.py b/lib/sqlalchemy/sql/operators.py
index ba1d0f65e..80f08a97c 100644
--- a/lib/sqlalchemy/sql/operators.py
+++ b/lib/sqlalchemy/sql/operators.py
@@ -14,7 +14,7 @@ from .. import util
from operator import (
and_, or_, inv, add, mul, sub, mod, truediv, lt, le, ne, gt, ge, eq, neg,
- getitem, lshift, rshift
+ getitem, lshift, rshift, contains
)
if util.py2k:
@@ -335,6 +335,9 @@ class ColumnOperators(Operators):
"""
return self.operate(neg)
+ def __contains__(self, other):
+ return self.operate(contains, other)
+
def __getitem__(self, index):
"""Implement the [] operator.