diff options
author | Ran Benita <ran234@gmail.com> | 2017-10-17 11:28:00 +0800 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2017-10-28 20:33:42 -0400 |
commit | 03049fb8d96ccd1f1ed0285486103542de42faba (patch) | |
tree | 243c0b4cc9b622a47ce7a665d36d8b4ab4973a0d /tests/filtered_relation | |
parent | 56b364bacca0d6a6cd8fbcd93aeb49f3ad46e58c (diff) | |
download | django-03049fb8d96ccd1f1ed0285486103542de42faba.tar.gz |
Refs #28010 -- Allowed reverse related fields in SELECT FOR UPDATE .. OF.
Thanks Adam Chidlow for polishing the patch.
Diffstat (limited to 'tests/filtered_relation')
-rw-r--r-- | tests/filtered_relation/tests.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/filtered_relation/tests.py b/tests/filtered_relation/tests.py index 4bae2216bf..2596dcbdc2 100644 --- a/tests/filtered_relation/tests.py +++ b/tests/filtered_relation/tests.py @@ -1,4 +1,4 @@ -from django.db import connection +from django.db import connection, transaction from django.db.models import Case, Count, F, FilteredRelation, Q, When from django.test import TestCase from django.test.testcases import skipUnlessDBFeature @@ -62,6 +62,20 @@ class FilteredRelationTests(TestCase): (self.book4, self.author1), ], lambda x: (x, x.author_join)) + @skipUnlessDBFeature('has_select_for_update', 'has_select_for_update_of') + def test_select_related_foreign_key_for_update_of(self): + with transaction.atomic(): + qs = Book.objects.annotate( + author_join=FilteredRelation('author'), + ).select_related('author_join').select_for_update(of=('self',)).order_by('pk') + with self.assertNumQueries(1): + self.assertQuerysetEqual(qs, [ + (self.book1, self.author1), + (self.book2, self.author2), + (self.book3, self.author2), + (self.book4, self.author1), + ], lambda x: (x, x.author_join)) + def test_without_join(self): self.assertSequenceEqual( Author.objects.annotate( |