`__len__()` or `__nonzero__()` method resulted in state
changes. [ticket:1501]
http://www.sqlalchemy.org/trac/wiki/UsageRecipes/PreFilteredQuery
for an example.
+ - Fixed recursion issue which occured if a mapped object's
+ `__len__()` or `__nonzero__()` method resulted in state
+ changes. [ticket:1501]
+
- Fixed a somewhat hypothetical issue which would result
in the wrong primary key being calculated for a mapper
using the old polymorphic_union function - but this
instance_dict._modified.add(self)
self.modified = True
- if not self._strong_obj:
+ if self._strong_obj is None:
self._strong_obj = self.obj()
def commit(self, dict_, keys):
sa.orm.eagerload_all('h3s.h1s')).all()
eq_(len(h1s), 5)
+ @testing.resolve_artifact_names
+ def test_nonzero_len_recursion(self):
+ class H1(object):
+ def __len__(self):
+ return len(self.get_value())
+
+ def get_value(self):
+ self.value = "foobar"
+ return self.value
+
+ class H2(object):
+ def __nonzero__(self):
+ return bool(self.get_value())
+ def get_value(self):
+ self.value = "foobar"
+ return self.value
+
+ mapper(H1, ht1)
+ mapper(H2, ht1)
+
+ h1 = H1()
+ h1.value = "Asdf"
+ h1.value = "asdf asdf" # ding
+
+ h2 = H2()
+ h2.value = "Asdf"
+ h2.value = "asdf asdf" # ding
+
class MagicNamesTest(_base.MappedTest):
@classmethod