Ticket #16759: 16759_cleaned_up_where_clone_for_1.3.1.diff

File 16759_cleaned_up_where_clone_for_1.3.1.diff, 3.8 KB (added by snyderra@…, 4 years ago)

patch that can be applied to the 1.3.1 stable release

  • django/db/models/sql/aggregates.py

    diff -ru Django-1.3.1/django/db/models/sql/aggregates.py Django-1.3.1_16759_cleaned_up_where_clone/django/db/models/sql/aggregates.py
    old new  
    6969
    7070        self.field = tmp
    7171
     72    def clone(self):
     73        return self
     74
    7275    def relabel_aliases(self, change_map):
    7376        if isinstance(self.col, (list, tuple)):
    7477            self.col = (change_map.get(self.col[0], self.col[0]), self.col[1])
  • django/db/models/sql/query.py

    diff -ru Django-1.3.1/django/db/models/sql/query.py Django-1.3.1_16759_cleaned_up_where_clone/django/db/models/sql/query.py
    old new  
    244244        obj.dupe_avoidance = self.dupe_avoidance.copy()
    245245        obj.select = self.select[:]
    246246        obj.tables = self.tables[:]
    247         obj.where = deepcopy(self.where, memo=memo)
     247        obj.where = self.where.clone()
    248248        obj.where_class = self.where_class
    249249        if self.group_by is None:
    250250            obj.group_by = None
    251251        else:
    252252            obj.group_by = self.group_by[:]
    253         obj.having = deepcopy(self.having, memo=memo)
     253        obj.having = self.having.clone()
    254254        obj.order_by = self.order_by[:]
    255255        obj.low_mark, obj.high_mark = self.low_mark, self.high_mark
    256256        obj.distinct = self.distinct
  • django/db/models/sql/where.py

    diff -ru Django-1.3.1/django/db/models/sql/where.py Django-1.3.1_16759_cleaned_up_where_clone/django/db/models/sql/where.py
    old new  
    261261    def relabel_aliases(self, change_map, node=None):
    262262        return
    263263
     264    def clone(self):
     265        return self
     266
    264267class NothingNode(object):
    265268    """
    266269    A node that matches nothing.
     
    271274    def relabel_aliases(self, change_map, node=None):
    272275        return
    273276
     277    def clone(self):
     278        return self
     279
    274280class ExtraWhere(object):
    275281    def __init__(self, sqls, params):
    276282        self.sqls = sqls
     
    279285    def as_sql(self, qn=None, connection=None):
    280286        return " AND ".join(self.sqls), tuple(self.params or ())
    281287
     288    def clone(self):
     289        return self
     290
    282291class Constraint(object):
    283292    """
    284293    An object that can be passed to WhereNode.add() and knows how to
     
    343352    def relabel_aliases(self, change_map):
    344353        if self.alias in change_map:
    345354            self.alias = change_map[self.alias]
     355
     356    def clone(self):
     357        return Constraint(self.alias, self.col, self.field)
  • django/utils/tree.py

    diff -ru Django-1.3.1/django/utils/tree.py Django-1.3.1_16759_cleaned_up_where_clone/django/utils/tree.py
    old new  
    4545        return obj
    4646    _new_instance = classmethod(_new_instance)
    4747
     48    def clone(self):
     49        clone = self.__class__._new_instance(
     50            children=[], connector=self.connector, negated=self.negated)
     51        for child in self.children:
     52            if isinstance(child, tuple):
     53                clone.children.append(
     54                    (child[0].clone(), child[1], child[2], child[3]))
     55            else:
     56                clone.children.append(child.clone())
     57        for parent in self.subtree_parents:
     58            clone.subtree_parents.append(parent.clone())
     59        return clone
     60
    4861    def __str__(self):
    4962        if self.negated:
    5063            return '(NOT (%s: %s))' % (self.connector, ', '.join([str(c) for c
Back to Top