Ticket #16759: query_carefull_clone.patch

File query_carefull_clone.patch, 1.5 KB (added by Suor, 3 years ago)
  • django/db/models/sql/where.py

     
    33"""
    44import datetime
    55from itertools import repeat
     6from copy import copy
    67
    78from django.utils import tree
    89from django.db.models.fields import Field
     
    286287    def __init__(self, alias, col, field):
    287288        self.alias, self.col, self.field = alias, col, field
    288289
     290    def __deepcopy__(self, memodict):
     291        return copy(self)
     292
    289293    def __getstate__(self):
    290294        """Save the state of the Constraint for pickling.
    291295
  • django/db/models/sql/expressions.py

     
    11from django.core.exceptions import FieldError
    22from django.db.models.fields import FieldDoesNotExist
    33from django.db.models.sql.constants import LOOKUP_SEP
     4from copy import deepcopy
    45
    56class SQLEvaluator(object):
    67    def __init__(self, expression, query, allow_joins=True):
     
    1112        self.contains_aggregate = False
    1213        self.expression.prepare(self, query, allow_joins)
    1314
     15    def __deepcopy__(self, memodict):
     16        memodict[id(self.opts)] = self.opts
     17
     18        obj = self.__class__.__new__(self.__class__)
     19        obj.__dict__ = deepcopy(self.__dict__, memodict)
     20        return obj
     21
    1422    def prepare(self):
    1523        return self
    1624
Back to Top