#34227: multi level FilteredRelation with select_related may set wrong related
object
-----------------------------------------+------------------------
               Reporter:  zhu            |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  Uncategorized  |        Version:  4.1
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 test case:
 {{{
 #!python
 # add to known_related_objects.tests.ExistingRelatedInstancesTests
     def test_wrong_select_related(self):
         with self.assertNumQueries(3):
             p = list(PoolStyle.objects.annotate(
 tournament_pool=FilteredRelation('pool__tournament__pool'),
                 ).select_related('tournament_pool'))
             self.assertEqual(p[0].pool.tournament,
 p[0].tournament_pool.tournament)

 }}}
 result:
 {{{
 ======================================================================
 FAIL: test_wrong_select_related
 
(known_related_objects.tests.ExistingRelatedInstancesTests.test_wrong_select_related)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "D:\Work\django\tests\known_related_objects\tests.py", line 171, in
 test_wrong_select_related
     self.assertEqual(p[0].pool.tournament,
 p[0].tournament_pool.tournament)
 AssertionError: <Tournament: Tournament object (1)> != <PoolStyle:
 PoolStyle object (1)>

 ----------------------------------------------------------------------
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34227>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701853efafbc9-6d3922fd-5c5d-4c80-a4fa-f8f26566ac6a-000000%40eu-central-1.amazonses.com.

Reply via email to