Fixed #13227 -- Modified ForeignKeys to fully honor the db_prep/prep separation introduced by multidb. This was required to ensure that model instances aren't deepcopied as a result of being involved in a filter clause. Thanks to claudep for the report, and Alex Gaynor for the help on the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12865 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee 2010-03-27 15:16:27 +00:00
parent 5256a805ff
commit b31b2d4da3
3 changed files with 64 additions and 30 deletions

View file

@ -155,7 +155,8 @@ class Q(tree.Node):
def _combine(self, other, conn):
if not isinstance(other, Q):
raise TypeError(other)
obj = deepcopy(self)
obj = type(self)()
obj.add(self, conn)
obj.add(other, conn)
return obj
@ -166,7 +167,8 @@ class Q(tree.Node):
return self._combine(other, self.AND)
def __invert__(self):
obj = deepcopy(self)
obj = type(self)()
obj.add(self, self.AND)
obj.negate()
return obj