summaryrefslogtreecommitdiff
path: root/django/db/models/query_utils.py
diff options
context:
space:
mode:
authorChris Cahoon <chris.cahoon@gmail.com>2009-06-13 03:28:54 +0000
committerChris Cahoon <chris.cahoon@gmail.com>2009-06-13 03:28:54 +0000
commitcb847aa2249d10b14ec53e419f4610e4e7d08811 (patch)
treeb9bed0e030d8c0d7b7035524941b78a27547a308 /django/db/models/query_utils.py
parentae2dd58ab12a59dc6459f5ff685639f8268de4da (diff)
Fixed #9479 -- Corrected an edge case in bulk queryset deletion that could cause an infinite loop when using MySQL InnoDB.
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/http-wsgi-improvements@10994 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/query_utils.py')
-rw-r--r--django/db/models/query_utils.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py
index 7a5ad919a1..6a6b69013f 100644
--- a/django/db/models/query_utils.py
+++ b/django/db/models/query_utils.py
@@ -32,11 +32,21 @@ class CollectedObjects(object):
This is used for the database object deletion routines so that we can
calculate the 'leaf' objects which should be deleted first.
+
+ previously_seen is an optional argument. It must be a CollectedObjects
+ instance itself; any previously_seen collected object will be blocked from
+ being added to this instance.
"""
- def __init__(self):
+ def __init__(self, previously_seen=None):
self.data = {}
self.children = {}
+ if previously_seen:
+ self.blocked = previously_seen.blocked
+ for cls, seen in previously_seen.data.items():
+ self.blocked.setdefault(cls, SortedDict()).update(seen)
+ else:
+ self.blocked = {}
def add(self, model, pk, obj, parent_model, nullable=False):
"""
@@ -53,6 +63,9 @@ class CollectedObjects(object):
Returns True if the item already existed in the structure and
False otherwise.
"""
+ if pk in self.blocked.get(model, {}):
+ return True
+
d = self.data.setdefault(model, SortedDict())
retval = pk in d
d[pk] = obj