Ticket #7231: extra-join-1.2-beta-SVN-12755.diff
File extra-join-1.2-beta-SVN-12755.diff, 3.1 KB (added by , 15 years ago) |
---|
-
django/db/models/sql/compiler.py
81 81 result.extend(from_) 82 82 params.extend(f_params) 83 83 84 if self.query.extra_join: 85 result.append(' '.join(self.query.extra_join)) 86 84 87 if where: 85 88 result.append('WHERE %s' % where) 86 89 params.extend(w_params) -
django/db/models/sql/query.py
130 130 131 131 self.extra_tables = () 132 132 self.extra_order_by = () 133 self.extra_join = () 133 134 134 135 # A tuple that is a set of model field names and either True, if these 135 136 # are the fields to defer, or False if these are the only fields to … … 256 257 obj._extra_select_cache = self._extra_select_cache.copy() 257 258 obj.extra_tables = self.extra_tables 258 259 obj.extra_order_by = self.extra_order_by 260 obj.extra_join = self.extra_join 259 261 obj.deferred_loading = deepcopy(self.deferred_loading, memo=memo) 260 262 if self.filter_is_sticky and self.used_aliases: 261 263 obj.used_aliases = self.used_aliases.copy() … … 376 378 377 379 def has_results(self, using): 378 380 q = self.clone() 379 q.add_extra({'a': 1}, None, None, None, None, None )381 q.add_extra({'a': 1}, None, None, None, None, None, None) 380 382 q.add_fields(()) 381 383 q.set_extra_mask(('a',)) 382 384 q.set_aggregate_mask(()) … … 1578 1580 self.related_select_cols = [] 1579 1581 self.related_select_fields = [] 1580 1582 1581 def add_extra(self, select, select_params, where, params, tables, order_by ):1583 def add_extra(self, select, select_params, where, params, tables, order_by, join) 1582 1584 """ 1583 1585 Adds data to the various extra_* attributes for user-created additions 1584 1586 to the query. … … 1609 1611 self.extra_tables += tuple(tables) 1610 1612 if order_by: 1611 1613 self.extra_order_by = order_by 1614 if join: 1615 self.extra_join += tuple(join) 1612 1616 1613 1617 def clear_deferred_loading(self): 1614 1618 """ -
django/db/models/query.py
648 648 return obj 649 649 650 650 def extra(self, select=None, where=None, params=None, tables=None, 651 order_by=None, select_params=None ):651 order_by=None, select_params=None, join=None): 652 652 """ 653 653 Adds extra SQL fragments to the query. 654 654 """ … … 656 656 "Cannot change a query once a slice has been taken" 657 657 clone = self._clone() 658 658 clone.query.add_extra(select, select_params, where, params, tables, order_by) 659 clone.query.add_extra(select, select_params, where, params, tables, order_by, join) 659 660 return clone 660 661 661 662 def reverse(self):