diff options
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( |
