diff options
author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2017-04-07 14:08:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-07 14:08:07 +0200 |
commit | 695d4dd7908ca32e118716b474c23b43727579d2 (patch) | |
tree | 703096795f68ee19e8b0c2233afb943d612d479e /tests/select_for_update | |
parent | 08df3dd937ce264c07117b10eae9a55651a63b43 (diff) | |
download | django-695d4dd7908ca32e118716b474c23b43727579d2.tar.gz |
Fixed #23147 -- Disabled a limit/offset on a query with select_for_update on Oracle.
Thanks Shai Berger and Tim Graham for the reviews.
Diffstat (limited to 'tests/select_for_update')
-rw-r--r-- | tests/select_for_update/tests.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/select_for_update/tests.py b/tests/select_for_update/tests.py index ac1d5b037e..d2a32840c7 100644 --- a/tests/select_for_update/tests.py +++ b/tests/select_for_update/tests.py @@ -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 |