Ticket #7231: extra-join-1.1b.2.diff
File extra-join-1.1b.2.diff, 2.6 KB (added by , 15 years ago) |
---|
-
django/db/models/sql/query.py
93 93 self.extra_where = () 94 94 self.extra_params = () 95 95 self.extra_order_by = () 96 self.extra_join_123 = () 96 97 97 98 # A tuple that is a set of model field names and either True, if these 98 99 # are the fields to defer, or False if these are the only fields to … … 211 212 obj.extra_where = self.extra_where 212 213 obj.extra_params = self.extra_params 213 214 obj.extra_order_by = self.extra_order_by 215 obj.extra_join_123 = self.extra_join_123 214 216 obj.deferred_loading = deepcopy(self.deferred_loading) 215 217 if self.filter_is_sticky and self.used_aliases: 216 218 obj.used_aliases = self.used_aliases.copy() … … 390 392 result.append('FROM') 391 393 result.extend(from_) 392 394 params.extend(f_params) 395 396 if self.extra_join_123: 397 result.append(' '.join(self.extra_join_123)) 393 398 394 399 if where: 395 400 result.append('WHERE %s' % where) … … 2095 2100 self.related_select_cols = [] 2096 2101 self.related_select_fields = [] 2097 2102 2098 def add_extra(self, select, select_params, where, params, tables, order_by ):2103 def add_extra(self, select, select_params, where, params, tables, order_by, join=None): 2099 2104 """ 2100 2105 Adds data to the various extra_* attributes for user-created additions 2101 2106 to the query. … … 2128 2133 self.extra_tables += tuple(tables) 2129 2134 if order_by: 2130 2135 self.extra_order_by = order_by 2136 if join: 2137 self.extra_join_123 += tuple(join) 2131 2138 2132 2139 def clear_deferred_loading(self): 2133 2140 """ -
django/db/models/query.py
570 570 return obj 571 571 572 572 def extra(self, select=None, where=None, params=None, tables=None, 573 order_by=None, select_params=None ):573 order_by=None, select_params=None, join=None): 574 574 """ 575 575 Adds extra SQL fragments to the query. 576 576 """ 577 577 assert self.query.can_filter(), \ 578 578 "Cannot change a query once a slice has been taken" 579 579 clone = self._clone() 580 clone.query.add_extra(select, select_params, where, params, tables, order_by )580 clone.query.add_extra(select, select_params, where, params, tables, order_by, join) 581 581 return clone 582 582 583 583 def reverse(self):