1
0
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:
Mariusz Felisiak
2017-04-07 14:08:07 +02:00
committed by GitHub
parent 08df3dd937
commit 695d4dd790
3 changed files with 28 additions and 2 deletions

View File

@@ -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