Ticket #11267: queries_by_attr_name_2.patch
File queries_by_attr_name_2.patch, 1.7 KB (added by , 15 years ago) |
---|
-
django/db/models/sql/query.py
1678 1678 self.used_aliases = used_aliases 1679 1679 1680 1680 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): 1683 1682 """ 1684 1683 Compute the necessary table joins for the passage through the fields 1685 1684 given in 'names'. 'opts' is the Options class for the current model … … 1715 1714 field, model, direct, m2m = opts.get_field_by_name(name) 1716 1715 except FieldDoesNotExist: 1717 1716 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: 1722 1718 field, model, direct, m2m = opts.get_field_by_name(f.name) 1723 1719 break 1724 1720 else: … … 2026 2022 try: 2027 2023 for name in field_names: 2028 2024 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) 2031 2026 final_alias = joins[-1] 2032 2027 col = target.column 2033 2028 if len(joins) > 1: