Ticket #7270: django_select_related_onetoone_r7534.patch
File django_select_related_onetoone_r7534.patch, 2.2 KB (added by , 16 years ago) |
---|
-
django/db/models/query.py
669 669 if cached_row: 670 670 rel_obj, index_end = cached_row 671 671 setattr(obj, f.get_cache_name(), rel_obj) 672 673 for f in klass._meta.get_all_related_objects(): 674 if restricted and f.field.related_query_name() not in requested: 675 continue 676 if restricted: 677 next = requested[f.field.related_query_name()] 678 else: 679 next = None 680 cached_row = get_cached_row(f.model, row, index_end, max_depth, cur_depth+1, next) 681 if cached_row: 682 rel_obj, index_end = cached_row 683 if rel_obj.pk: 684 setattr(obj, f.field.get_cache_name(), rel_obj) 685 else: 686 setattr(obj, f.field.get_cache_name(), None) 687 672 688 return obj, index_end 673 689 674 690 def delete_objects(seen_objs): -
django/db/models/sql/query.py
908 908 self.fill_related_selections(f.rel.to._meta, alias, cur_depth + 1, 909 909 used, next, restricted) 910 910 911 for f in opts.get_all_related_objects(): 912 if restricted and f.field.related_query_name() not in requested: 913 continue 914 table = f.model._meta.db_table 915 alias = root_alias 916 alias = self.join((alias, table, 'id', f.field.column), exclusions=used, promote=True) 917 used.add(alias) 918 self.related_select_cols.extend([(alias, f2.column) for f2 in f.model._meta.fields]) 919 self.related_select_fields.extend(f.model._meta.fields) 920 if restricted: 921 next = requested.get(f.name, {}) 922 else: 923 next = False 924 self.fill_related_selections(f.model._meta, alias, cur_depth + 1, used, next, restricted) 925 911 926 def add_filter(self, filter_expr, connector=AND, negate=False, trim=False, 912 927 can_reuse=None): 913 928 """