From: Jason Kirtland Date: Thu, 24 Jan 2008 01:12:46 +0000 (+0000) Subject: - Flipped join order of __radd__ on association proxied lists. X-Git-Tag: rel_0_4_3~72 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed740839564502a04fe8b2d07b2232d0d7383323;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Flipped join order of __radd__ on association proxied lists. --- diff --git a/CHANGES b/CHANGES index 947ee36035..4f1d422c06 100644 --- a/CHANGES +++ b/CHANGES @@ -140,6 +140,9 @@ CHANGES - Changed ext.activemapper to use a non-transactional session for the objectstore. + - Fixed output order of "['a'] + obj.proxied" binary operation on + association-proxied lists. + 0.4.2p3 ------ - general diff --git a/lib/sqlalchemy/ext/associationproxy.py b/lib/sqlalchemy/ext/associationproxy.py index e9f6040058..1e237a8576 100644 --- a/lib/sqlalchemy/ext/associationproxy.py +++ b/lib/sqlalchemy/ext/associationproxy.py @@ -408,7 +408,13 @@ class _AssociationList(object): except TypeError: return NotImplemented return list(self) + other - __radd__ = __add__ + + def __radd__(self, iterable): + try: + other = list(iterable) + except TypeError: + return NotImplemented + return other + list(self) def __mul__(self, n): if not isinstance(n, int): diff --git a/test/ext/associationproxy.py b/test/ext/associationproxy.py index aca5263fba..1ebf07cb31 100644 --- a/test/ext/associationproxy.py +++ b/test/ext/associationproxy.py @@ -199,13 +199,18 @@ class _CollectionOperations(PersistTest): self.assert_(p1.children == after) self.assert_([c.name for c in p1._children] == after) + p1.children += ['c'] + after = ['a', 'b', 'c'] + self.assert_(p1.children == after) + self.assert_([c.name for c in p1._children] == after) + p1.children *= 1 - after = ['a', 'b'] + after = ['a', 'b', 'c'] self.assert_(p1.children == after) self.assert_([c.name for c in p1._children] == after) p1.children *= 2 - after = ['a', 'b', 'a', 'b'] + after = ['a', 'b', 'c', 'a', 'b', 'c'] self.assert_(p1.children == after) self.assert_([c.name for c in p1._children] == after) @@ -219,8 +224,8 @@ class _CollectionOperations(PersistTest): self.assert_((p1.children * 0) == []) self.assert_((0 * p1.children) == []) - self.assert_((p1.children + ['a']) == ['a', 'a']) - self.assert_((['a'] + p1.children) == ['a', 'a']) + self.assert_((p1.children + ['b']) == ['a', 'b']) + self.assert_((['b'] + p1.children) == ['b', 'a']) try: p1.children + 123