Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.1.X] Refs #13227 -- Partial backport of r12865; backported the cha…

…nges to Where tree cloning logic to ensure that unclonable objects in a where() clause don't break querying.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12963 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit cf08ea496e9d40f2f5b3677feedb59cd600fab91 1 parent ee2b07c
@freakboy3742 freakboy3742 authored
View
6 django/db/models/query_utils.py
@@ -152,7 +152,8 @@ def __init__(self, *args, **kwargs):
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
@@ -163,7 +164,8 @@ def __and__(self, other):
return self._combine(other, self.AND)
def __invert__(self):
- obj = deepcopy(self)
+ obj = type(self)()
+ obj.add(self, self.AND)
obj.negate()
return obj
View
8 tests/regressiontests/queries/models.py
@@ -5,6 +5,7 @@
import datetime
import pickle
import sys
+import threading
from django.conf import settings
from django.db import models
@@ -44,6 +45,13 @@ class Meta:
def __unicode__(self):
return self.note
+ def __init__(self, *args, **kwargs):
+ super(Note, self).__init__(*args, **kwargs)
+ # Regression for #13227 -- having an attribute that
+ # is unpickleable doesn't stop you from cloning queries
+ # that use objects of that type as an argument.
+ self.lock = threading.Lock()
+
class Annotation(models.Model):
name = models.CharField(max_length=10)
tag = models.ForeignKey(Tag)
Please sign in to comment.
Something went wrong with that request. Please try again.