mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #27193 -- Preserved ordering in select_for_update subqueries.
This commit is contained in:
parent
9e26a8331d
commit
8ac115c730
2 changed files with 14 additions and 2 deletions
|
@ -300,3 +300,12 @@ class SelectForUpdateTests(TransactionTestCase):
|
|||
def test_nowait_and_skip_locked(self):
|
||||
with self.assertRaisesMessage(ValueError, 'The nowait option cannot be used with skip_locked.'):
|
||||
Person.objects.select_for_update(nowait=True, skip_locked=True)
|
||||
|
||||
def test_ordered_select_for_update(self):
|
||||
"""
|
||||
Subqueries should respect ordering as an ORDER BY clause may be useful
|
||||
to specify a row locking order to prevent deadlocks (#27193).
|
||||
"""
|
||||
with transaction.atomic():
|
||||
qs = Person.objects.filter(id__in=Person.objects.order_by('-id').select_for_update())
|
||||
self.assertIn('ORDER BY', str(qs.query))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue