Ticket #10790: django1.1-ticket10790.patch

File django1.1-ticket10790.patch, 5.2 KB (added by milosu, 15 years ago)

patch for django 1.1 passing django 1.1 regression test suite

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

     
    3939            self.cols[node] = query.aggregate_select[node.name]
    4040        else:
    4141            try:
    42                 field, source, opts, join_list, last, _ = query.setup_joins(
     42                field, source, opts, join_list, last, _, allow_trim_join = query.setup_joins(
    4343                    field_list, query.get_meta(),
    4444                    query.get_initial_alias(), False)
    4545                col, _, join_list = query.trim_joins(source, join_list, last, False)
  • django/db/models/sql/query.py

     
    991991        pieces = name.split(LOOKUP_SEP)
    992992        if not alias:
    993993            alias = self.get_initial_alias()
    994         field, target, opts, joins, last, extra = self.setup_joins(pieces,
     994        field, target, opts, joins, last, extra, allow_trim_join = self.setup_joins(pieces,
    995995                opts, alias, False)
    996996        alias = joins[-1]
    997997        col = target.column
     
    14741474            #   - this is an annotation over a model field
    14751475            # then we need to explore the joins that are required.
    14761476
    1477             field, source, opts, join_list, last, _ = self.setup_joins(
     1477            field, source, opts, join_list, last, _, allow_trim_join = self.setup_joins(
    14781478                field_list, opts, self.get_initial_alias(), False)
    14791479
    14801480            # Process the join chain to see if it can be trimmed
     
    15711571        allow_many = trim or not negate
    15721572
    15731573        try:
    1574             field, target, opts, join_list, last, extra_filters = self.setup_joins(
     1574            field, target, opts, join_list, last, extra_filters, allow_trim_join = self.setup_joins(
    15751575                    parts, opts, alias, True, allow_many, can_reuse=can_reuse,
    15761576                    negate=negate, process_extras=process_extras)
    15771577        except MultiJoin, e:
     
    15841584            # If the comparison is against NULL, we may need to use some left
    15851585            # outer joins when creating the join chain. This is only done when
    15861586            # needed, as it's less efficient at the database level.
    1587             self.promote_alias_chain(join_list)
    15881587
     1588            # If we have a one2one or many2one field, we can trim the left outer
     1589            # join from the end of a list of joins.
     1590            # We do not promote left outer join in this case so that trim_joins can
     1591            # do it for us.
     1592            if not (allow_trim_join and field.rel):
     1593                self.promote_alias_chain(join_list)
     1594
    15891595        # Process the join list to see if we can remove any inner joins from
    15901596        # the far end (fewer tables in a query is better).
    15911597        col, alias, join_list = self.trim_joins(target, join_list, last, trim)
     
    17191725        dupe_set = set()
    17201726        exclusions = set()
    17211727        extra_filters = []
     1728        allow_trim_join = True
    17221729        for pos, name in enumerate(names):
    17231730            try:
    17241731                exclusions.add(int_alias)
     
    17431750                    raise FieldError("Cannot resolve keyword %r into field. "
    17441751                            "Choices are: %s" % (name, ", ".join(names)))
    17451752
     1753            # presence of indirect field in the filter requires
     1754            # left outer join for isnull
     1755            if not direct and allow_trim_join:
     1756                allow_trim_join = False
     1757
    17461758            if not allow_many and (m2m or not direct):
    17471759                for alias in joins:
    17481760                    self.unref_alias(alias)
     
    17841796                extra_filters.extend(field.extra_filters(names, pos, negate))
    17851797            if direct:
    17861798                if m2m:
     1799                    # null query on m2mfield requires outer join
     1800                    allow_trim_join = False
    17871801                    # Many-to-many field defined on the current model.
    17881802                    if cached_data:
    17891803                        (table1, from_col1, to_col1, table2, from_col2,
     
    18931907            else:
    18941908                raise FieldError("Join on field %r not permitted." % name)
    18951909
    1896         return field, target, opts, joins, last, extra_filters
     1910        return field, target, opts, joins, last, extra_filters, allow_trim_join
    18971911
    18981912    def trim_joins(self, target, join_list, last, trim):
    18991913        """
     
    20422056
    20432057        try:
    20442058            for name in field_names:
    2045                 field, target, u2, joins, u3, u4 = self.setup_joins(
     2059                field, target, u2, joins, u3, u4, allow_trim_join = self.setup_joins(
    20462060                        name.split(LOOKUP_SEP), opts, alias, False, allow_m2m,
    20472061                        True)
    20482062                final_alias = joins[-1]
     
    23262340        """
    23272341        opts = self.model._meta
    23282342        alias = self.get_initial_alias()
    2329         field, col, opts, joins, last, extra = self.setup_joins(
     2343        field, col, opts, joins, last, extra, allow_trim_join = self.setup_joins(
    23302344                start.split(LOOKUP_SEP), opts, alias, False)
    23312345        select_col = self.alias_map[joins[1]][LHS_JOIN_COL]
    23322346        select_alias = alias
Back to Top