Ticket #7231: extra-join-1.2-beta-SVN-12755.diff

File extra-join-1.2-beta-SVN-12755.diff, 3.1 KB (added by bendavis78, 5 years ago)

Updated for django 1.2-beta

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

     
    8181        result.extend(from_)
    8282        params.extend(f_params)
    8383
     84        if self.query.extra_join:
     85            result.append(' '.join(self.query.extra_join))
     86
    8487        if where:
    8588            result.append('WHERE %s' % where)
    8689            params.extend(w_params)
  • django/db/models/sql/query.py

     
    130130
    131131        self.extra_tables = ()
    132132        self.extra_order_by = ()
     133        self.extra_join = ()
    133134
    134135        # A tuple that is a set of model field names and either True, if these
    135136        # are the fields to defer, or False if these are the only fields to
     
    256257            obj._extra_select_cache = self._extra_select_cache.copy()
    257258        obj.extra_tables = self.extra_tables
    258259        obj.extra_order_by = self.extra_order_by
     260        obj.extra_join = self.extra_join
    259261        obj.deferred_loading = deepcopy(self.deferred_loading, memo=memo)
    260262        if self.filter_is_sticky and self.used_aliases:
    261263            obj.used_aliases = self.used_aliases.copy()
     
    376378
    377379    def has_results(self, using):
    378380        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)
    380382        q.add_fields(())
    381383        q.set_extra_mask(('a',))
    382384        q.set_aggregate_mask(())
     
    15781580        self.related_select_cols = []
    15791581        self.related_select_fields = []
    15801582
    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)
    15821584        """
    15831585        Adds data to the various extra_* attributes for user-created additions
    15841586        to the query.
     
    16091611            self.extra_tables += tuple(tables)
    16101612        if order_by:
    16111613            self.extra_order_by = order_by
     1614        if join:
     1615            self.extra_join += tuple(join)
    16121616
    16131617    def clear_deferred_loading(self):
    16141618        """
  • django/db/models/query.py

     
    648648        return obj
    649649
    650650    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):
    652652        """
    653653        Adds extra SQL fragments to the query.
    654654        """
     
    656656                "Cannot change a query once a slice has been taken"
    657657        clone = self._clone()
    658658        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)
    659660        return clone
    660661
    661662    def reverse(self):
Back to Top