Ticket #11267: queries_by_attr_name_2.patch

File queries_by_attr_name_2.patch, 1.7 KB (added by dstora, 10 years ago)

Patch 2

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

     
    16781678            self.used_aliases = used_aliases
    16791679
    16801680    def setup_joins(self, names, opts, alias, dupe_multis, allow_many=True,
    1681             allow_explicit_fk=False, can_reuse=None, negate=False,
    1682             process_extras=True):
     1681            can_reuse=None, negate=False, process_extras=True):
    16831682        """
    16841683        Compute the necessary table joins for the passage through the fields
    16851684        given in 'names'. 'opts' is the Options class for the current model
     
    17151714                field, model, direct, m2m = opts.get_field_by_name(name)
    17161715            except FieldDoesNotExist:
    17171716                for f in opts.fields:
    1718                     if allow_explicit_fk and name == f.attname:
    1719                         # XXX: A hack to allow foo_id to work in values() for
    1720                         # backwards compatibility purposes. If we dropped that
    1721                         # feature, this could be removed.
     1717                    if name == f.attname:
    17221718                        field, model, direct, m2m = opts.get_field_by_name(f.name)
    17231719                        break
    17241720                else:
     
    20262022        try:
    20272023            for name in field_names:
    20282024                field, target, u2, joins, u3, u4 = self.setup_joins(
    2029                         name.split(LOOKUP_SEP), opts, alias, False, allow_m2m,
    2030                         True)
     2025                        name.split(LOOKUP_SEP), opts, alias, False, allow_m2m)
    20312026                final_alias = joins[-1]
    20322027                col = target.column
    20332028                if len(joins) > 1:
Back to Top