:version: 0.8.0b2
.. change::
- :tags: orm, extensions
+ :tags: sql, bug
+
+ 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__()``.
+
+ .. change::
+ :tags: orm, extensions, feature
The :mod:`sqlalchemy.ext.mutable` extension now includes the
example :class:`.MutableDict` class as part of the extension.
.. change::
- :tags: postgresql, hstore
+ :tags: postgresql, feature
:tickets: 2606
:class:`.HSTORE` is now available in the Postgresql dialect.
"""
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.
def test_cols_keys(self):
self._test_cols(
- self.hashcol.keys(),
+ # hide from 2to3
+ getattr(self.hashcol, 'keys')(),
"akeys(test_table.hash) AS akeys_1",
True
)
"x -> :x_1"
)
+ def test_no_endless_list_call(self):
+ class MyType(UserDefinedType):
+ class comparator_factory(UserDefinedType.Comparator):
+ def __getitem__(self, index):
+ return self.op("->")(index)
+
+ assert_raises_message(
+ NotImplementedError,
+ "Class <class 'sqlalchemy.schema.Column'> is not iterable",
+ list, Column('x', MyType())
+ )
+
def test_lshift(self):
class MyType(UserDefinedType):
class comparator_factory(UserDefinedType.Comparator):