mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #33260 -- Fixed crash when chaining QuerySet.exists() after select_for_update(of=()).
This commit is contained in:
parent
447b6c866f
commit
25157033e9
@ -1077,6 +1077,8 @@ class SQLCompiler:
|
|||||||
(path, klass_info)
|
(path, klass_info)
|
||||||
for klass_info in klass_info.get('related_klass_infos', [])
|
for klass_info in klass_info.get('related_klass_infos', [])
|
||||||
)
|
)
|
||||||
|
if not self.klass_info:
|
||||||
|
return []
|
||||||
result = []
|
result = []
|
||||||
invalid_names = []
|
invalid_names = []
|
||||||
for name in self.query.select_for_update_of:
|
for name in self.query.select_for_update_of:
|
||||||
|
@ -244,6 +244,14 @@ class SelectForUpdateTests(TransactionTestCase):
|
|||||||
values = list(Person.objects.select_related('born').select_for_update(of=('self',)).values('born__name'))
|
values = list(Person.objects.select_related('born').select_for_update(of=('self',)).values('born__name'))
|
||||||
self.assertEqual(values, [{'born__name': self.city1.name}])
|
self.assertEqual(values, [{'born__name': self.city1.name}])
|
||||||
|
|
||||||
|
@skipUnlessDBFeature(
|
||||||
|
'has_select_for_update_of', 'supports_select_for_update_with_limit',
|
||||||
|
)
|
||||||
|
def test_for_update_of_with_exists(self):
|
||||||
|
with transaction.atomic():
|
||||||
|
qs = Person.objects.select_for_update(of=('self', 'born'))
|
||||||
|
self.assertIs(qs.exists(), True)
|
||||||
|
|
||||||
@skipUnlessDBFeature('has_select_for_update_nowait')
|
@skipUnlessDBFeature('has_select_for_update_nowait')
|
||||||
def test_nowait_raises_error_on_block(self):
|
def test_nowait_raises_error_on_block(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user