summaryrefslogtreecommitdiff
path: root/tests/select_for_update
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2017-12-23 11:35:08 +0200
committerTim Graham <timograham@gmail.com>2017-12-26 11:41:17 -0500
commitc21f158295d92e35caf96436bfdbbff554fc5569 (patch)
treecca717940ef8c52d3d70e5070c90f0be23ceb136 /tests/select_for_update
parent5778b5701d6a0feb3053b70891cd8ce80b6e8601 (diff)
downloaddjango-c21f158295d92e35caf96436bfdbbff554fc5569.tar.gz
Fixed #28944 -- Fixed crash when chaining values()/values_list() after QuerySet.select_for_update(of=()).
Diffstat (limited to 'tests/select_for_update')
-rw-r--r--tests/select_for_update/tests.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/select_for_update/tests.py b/tests/select_for_update/tests.py
index 6de268cb2b..a750dc61db 100644
--- a/tests/select_for_update/tests.py
+++ b/tests/select_for_update/tests.py
@@ -120,6 +120,28 @@ class SelectForUpdateTests(TransactionTestCase):
expected = [value.upper() for value in expected]
self.assertTrue(self.has_for_update_sql(ctx.captured_queries, of=expected))
+ @skipUnlessDBFeature('has_select_for_update_of')
+ def test_for_update_of_followed_by_values(self):
+ with transaction.atomic():
+ values = list(Person.objects.select_for_update(of=('self',)).values('pk'))
+ self.assertEqual(values, [{'pk': self.person.pk}])
+
+ @skipUnlessDBFeature('has_select_for_update_of')
+ def test_for_update_of_followed_by_values_list(self):
+ with transaction.atomic():
+ values = list(Person.objects.select_for_update(of=('self',)).values_list('pk'))
+ self.assertEqual(values, [(self.person.pk,)])
+
+ @skipUnlessDBFeature('has_select_for_update_of')
+ def test_for_update_of_self_when_self_is_not_selected(self):
+ """
+ select_for_update(of=['self']) when the only columns selected are from
+ related tables.
+ """
+ with transaction.atomic():
+ values = list(Person.objects.select_related('born').select_for_update(of=('self',)).values('born__name'))
+ self.assertEqual(values, [{'born__name': self.city1.name}])
+
@skipUnlessDBFeature('has_select_for_update_nowait')
def test_nowait_raises_error_on_block(self):
"""