Ticket #16759: 16759_cleaned_up_where_clone.diff
File 16759_cleaned_up_where_clone.diff, 3.4 KB (added by , 13 years ago) |
---|
-
django/db/models/sql/aggregates.py
69 69 70 70 self.field = tmp 71 71 72 def clone(self): 73 return self 74 72 75 def relabel_aliases(self, change_map): 73 76 if isinstance(self.col, (list, tuple)): 74 77 self.col = (change_map.get(self.col[0], self.col[0]), self.col[1]) -
django/db/models/sql/where.py
260 260 def relabel_aliases(self, change_map, node=None): 261 261 return 262 262 263 def clone(self): 264 return self 265 263 266 class NothingNode(object): 264 267 """ 265 268 A node that matches nothing. … … 270 273 def relabel_aliases(self, change_map, node=None): 271 274 return 272 275 276 def clone(self): 277 return self 278 273 279 class ExtraWhere(object): 274 280 def __init__(self, sqls, params): 275 281 self.sqls = sqls … … 278 284 def as_sql(self, qn=None, connection=None): 279 285 return " AND ".join(self.sqls), tuple(self.params or ()) 280 286 287 def clone(self): 288 return self 289 281 290 class Constraint(object): 282 291 """ 283 292 An object that can be passed to WhereNode.add() and knows how to … … 342 351 def relabel_aliases(self, change_map): 343 352 if self.alias in change_map: 344 353 self.alias = change_map[self.alias] 354 355 def clone(self): 356 return Constraint(self.alias, self.col, self.field) -
django/db/models/sql/query.py
254 254 obj.dupe_avoidance = self.dupe_avoidance.copy() 255 255 obj.select = self.select[:] 256 256 obj.tables = self.tables[:] 257 obj.where = copy.deepcopy(self.where, memo=memo)257 obj.where = self.where.clone() 258 258 obj.where_class = self.where_class 259 259 if self.group_by is None: 260 260 obj.group_by = None 261 261 else: 262 262 obj.group_by = self.group_by[:] 263 obj.having = copy.deepcopy(self.having, memo=memo)263 obj.having = self.having.clone() 264 264 obj.order_by = self.order_by[:] 265 265 obj.low_mark, obj.high_mark = self.low_mark, self.high_mark 266 266 obj.distinct = self.distinct -
django/utils/tree.py
45 45 return obj 46 46 _new_instance = classmethod(_new_instance) 47 47 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 48 61 def __str__(self): 49 62 if self.negated: 50 63 return '(NOT (%s: %s))' % (self.connector, ', '.join([str(c) for c