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