summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/attributes.py5
-rw-r--r--lib/sqlalchemy/mapping/properties.py4
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/sqlalchemy/attributes.py b/lib/sqlalchemy/attributes.py
index bd5868baf..997b2c8f8 100644
--- a/lib/sqlalchemy/attributes.py
+++ b/lib/sqlalchemy/attributes.py
@@ -144,6 +144,8 @@ class ListElement(util.HistoryArraySet):
# list that might be set on the object already
try:
list_ = obj.__dict__[key]
+ if list_ is data:
+ raise InvalidArgumentError("Creating a list element passing the object's list as an argument")
if data is not None:
for d in data:
list_.append(d)
@@ -435,8 +437,7 @@ class AttributeManager(object):
elif not uselist:
return PropHistory(obj, key, **kwargs)
else:
- list_ = obj.__dict__.get(key, None)
- return self.create_list(obj, key, list_, **kwargs)
+ return self.create_list(obj, key, None, **kwargs)
def register_attribute(self, class_, key, uselist, callable_=None, **kwargs):
"""registers an attribute's behavior at the class level. This attribute
diff --git a/lib/sqlalchemy/mapping/properties.py b/lib/sqlalchemy/mapping/properties.py
index 7f5489de6..10d6472f4 100644
--- a/lib/sqlalchemy/mapping/properties.py
+++ b/lib/sqlalchemy/mapping/properties.py
@@ -449,6 +449,8 @@ class PropertyLoader(MapperProperty):
for obj in deplist:
childlist = getlist(obj, False)
for child in childlist.deleted_items() + childlist.unchanged_items():
+ if child is None:
+ continue
uowcommit.register_object(child, isdelete=True)
elif self.post_update:
# post_update means we have to update our row to not reference the child object
@@ -467,6 +469,8 @@ class PropertyLoader(MapperProperty):
for obj in deplist:
childlist = getlist(obj, False)
for child in childlist.deleted_items() + childlist.unchanged_items():
+ if child is None:
+ continue
uowcommit.register_object(child, isdelete=True)
else:
for obj in deplist: