mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #23147 -- Disabled a limit/offset on a query with select_for_update on Oracle.
Thanks Shai Berger and Tim Graham for the reviews.
This commit is contained in:
@@ -5,7 +5,8 @@ from unittest import mock
|
||||
from multiple_database.routers import TestRouter
|
||||
|
||||
from django.db import (
|
||||
DatabaseError, connection, connections, router, transaction,
|
||||
DatabaseError, NotSupportedError, connection, connections, router,
|
||||
transaction,
|
||||
)
|
||||
from django.test import (
|
||||
TransactionTestCase, override_settings, skipIfDBFeature,
|
||||
@@ -179,6 +180,20 @@ class SelectForUpdateTests(TransactionTestCase):
|
||||
with self.assertRaises(transaction.TransactionManagementError):
|
||||
list(people)
|
||||
|
||||
@skipUnlessDBFeature('supports_select_for_update_with_limit')
|
||||
def test_select_for_update_with_limit(self):
|
||||
other = Person.objects.create(name='Grappeli')
|
||||
with transaction.atomic():
|
||||
qs = list(Person.objects.all().order_by('pk').select_for_update()[1:2])
|
||||
self.assertEqual(qs[0], other)
|
||||
|
||||
@skipIfDBFeature('supports_select_for_update_with_limit')
|
||||
def test_unsupported_select_for_update_with_limit(self):
|
||||
msg = 'LIMIT/OFFSET not supported with select_for_update on this database backend.'
|
||||
with self.assertRaisesMessage(NotSupportedError, msg):
|
||||
with transaction.atomic():
|
||||
list(Person.objects.all().order_by('pk').select_for_update()[1:2])
|
||||
|
||||
def run_select_for_update(self, status, **kwargs):
|
||||
"""
|
||||
Utility method that runs a SELECT FOR UPDATE against all
|
||||
|
||||
Reference in New Issue
Block a user