summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJason Kirtland <jek@discorporate.us>2007-04-19 19:07:51 +0000
committerJason Kirtland <jek@discorporate.us>2007-04-19 19:07:51 +0000
commit47a6af93d5b05202a38d66d471edd4122f2aa9a2 (patch)
tree48c8a5f7a66fb18a196d76720656550d51a96f55 /lib
parentb90627a44f1cef68eb4c9f29969489a5e3a9ce9f (diff)
downloadsqlalchemy-47a6af93d5b05202a38d66d471edd4122f2aa9a2.tar.gz
- fixed issue where slice assignment on relation properties truncates the relation (#529)
- fix for #530, don't require collection classes to respond to len requests
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/orm/attributes.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py
index 699a2f887..f706ca7e7 100644
--- a/lib/sqlalchemy/orm/attributes.py
+++ b/lib/sqlalchemy/orm/attributes.py
@@ -566,16 +566,18 @@ class InstrumentedList(object):
def __contains__(self, item): return item in self.data
- def __len__(self): return len(self.data)
+ def __len__(self):
+ try:
+ return len(self.data)
+ except TypeError:
+ return len(list(self.data))
def __setslice__(self, i, j, other):
- i = max(i, 0); j = max(j, 0)
- [self.__delrecord(x) for x in self.data[i:]]
+ [self.__delrecord(x) for x in self.data[i:j]]
g = [a for a in list(other) if self.__setrecord(a)]
- self.data[i:] = g
+ self.data[i:j] = g
def __delslice__(self, i, j):
- i = max(i, 0); j = max(j, 0)
for a in self.data[i:j]:
self.__delrecord(a)
del self.data[i:j]