Changeset 8098
- Timestamp:
- 07/26/08 20:18:23 (6 months ago)
- Files:
-
- django/trunk/django/db/models/query.py (modified) (1 diff)
- django/trunk/tests/regressiontests/null_fk/models.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/db/models/query.py
r7938 r8098 786 786 restricted = requested is not None 787 787 index_end = index_start + len(klass._meta.fields) 788 obj = klass(*row[index_start:index_end]) 788 fields = row[index_start:index_end] 789 if not [x for x in fields if x is not None]: 790 # If we only have a list of Nones, there was not related object. 791 return None, index_end 792 obj = klass(*fields) 789 793 for f in klass._meta.fields: 790 794 if not select_related_descend(f, restricted, requested): django/trunk/tests/regressiontests/null_fk/models.py
r7597 r8098 1 1 """ 2 Regression tests for proper working of ForeignKey(null=True). Tests these bugs: 3 4 * #7369: FK non-null after null relationship on select_related() generates an invalid query 5 2 Regression tests for proper working of ForeignKey(null=True). 6 3 """ 7 4 … … 39 36 # Starting from comment, make sure that a .select_related(...) with a specified 40 37 # set of fields will properly LEFT JOIN multiple levels of NULLs (and the things 41 # that come after the NULLs, or else data that should exist won't). 38 # that come after the NULLs, or else data that should exist won't). Regression 39 # test for #7369. 42 40 >>> c = Comment.objects.select_related().get(id=1) 43 41 >>> c.post … … 48 46 49 47 >>> comments = Comment.objects.select_related('post__forum__system_info').all() 50 >>> [(c.id, c.post.id) for c in comments] 51 [(1, 1), (2, None)] 52 >>> [(c.comment_text, c.post.title) for c in comments] 53 [(u'My first comment', u'First Post'), (u'My second comment', None)] 48 >>> [(c.id, c.comment_text, c.post) for c in comments] 49 [(1, u'My first comment', <Post: First Post>), (2, u'My second comment', None)] 50 51 # Regression test for #7530, #7716. 52 >>> Comment.objects.select_related('post').filter(post__isnull=True)[0].post is None 53 True 54 54 55 55 """}
