summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/operators.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-11-18 10:38:02 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2012-11-18 10:38:02 -0500
commit1e29a74bd62c6c872819388e430901c35f84f07c (patch)
tree98fedf95477a04dd2adf570aba965e248935570d /lib/sqlalchemy/sql/operators.py
parent0f56aa56c5de13ab14bd8e8d03b6e785c39a5bf0 (diff)
downloadsqlalchemy-1e29a74bd62c6c872819388e430901c35f84f07c.tar.gz
Fixed a gotcha where inadvertently calling list() on a
:class:`.ColumnElement` would go into an endless loop, if :meth:`.ColumnOperators.__getitem__` were implemented. A new NotImplementedError is emitted via ``__iter__()``.
Diffstat (limited to 'lib/sqlalchemy/sql/operators.py')
-rw-r--r--lib/sqlalchemy/sql/operators.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/operators.py b/lib/sqlalchemy/sql/operators.py
index 88f56e5ec..7513c0b82 100644
--- a/lib/sqlalchemy/sql/operators.py
+++ b/lib/sqlalchemy/sql/operators.py
@@ -310,6 +310,11 @@ class ColumnOperators(Operators):
"""
return self.operate(neg)
+ def __iter__(self):
+ """Block calls to list() from calling __getitem__() endlessly."""
+
+ raise NotImplementedError("Class %s is not iterable" % self.__class__)
+
def __getitem__(self, index):
"""Implement the [] operator.