Ticket #7231: extra-join-1.0.diff
File extra-join-1.0.diff, 2.4 KB (added by , 16 years ago) |
---|
-
django/db/models/sql/query.py
85 85 self.extra_where = () 86 86 self.extra_params = () 87 87 self.extra_order_by = () 88 self.extra_join = () 88 89 89 90 def __str__(self): 90 91 """ … … 187 188 obj.extra_where = self.extra_where 188 189 obj.extra_params = self.extra_params 189 190 obj.extra_order_by = self.extra_order_by 191 obj.extra_join = self.extra_join 190 192 if self.filter_is_sticky and self.used_aliases: 191 193 obj.used_aliases = self.used_aliases.copy() 192 194 else: … … 277 279 result.append('FROM') 278 280 result.extend(from_) 279 281 params.extend(f_params) 282 283 if self.extra_join: 284 result.append(' '.join(self.extra_join)) 280 285 281 286 if where: 282 287 result.append('WHERE %s' % where) … … 1625 1630 self.related_select_cols = [] 1626 1631 self.related_select_fields = [] 1627 1632 1628 def add_extra(self, select, select_params, where, params, tables, order_by ):1633 def add_extra(self, select, select_params, where, params, tables, order_by, join): 1629 1634 """ 1630 1635 Adds data to the various extra_* attributes for user-created additions 1631 1636 to the query. … … 1658 1663 self.extra_tables += tuple(tables) 1659 1664 if order_by: 1660 1665 self.extra_order_by = order_by 1666 if join: 1667 self.extra_join += tuple(join) 1661 1668 1662 1669 def trim_extra_select(self, names): 1663 1670 """ -
django/db/models/query.py
567 567 return obj 568 568 569 569 def extra(self, select=None, where=None, params=None, tables=None, 570 order_by=None, select_params=None ):570 order_by=None, select_params=None, join=None): 571 571 """ 572 572 Adds extra SQL fragments to the query. 573 573 """ 574 574 assert self.query.can_filter(), \ 575 575 "Cannot change a query once a slice has been taken" 576 576 clone = self._clone() 577 clone.query.add_extra(select, select_params, where, params, tables, order_by )577 clone.query.add_extra(select, select_params, where, params, tables, order_by, join) 578 578 return clone 579 579 580 580 def reverse(self):