From 2a6b4e65214ff60ee50b14fb33916a2b58e9fcbe Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Tue, 11 Apr 2017 18:52:53 +0300 Subject: [PATCH] Updated docs after changing select_for_update() to raise NotSupportedError. Follow up to 054a44d6f0f75395bd02a21e31ea904a24750a2b. --- docs/ref/databases.txt | 3 ++- docs/ref/models/querysets.txt | 4 ++-- tests/select_for_update/tests.py | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt index 42e335c9c6..7960688202 100644 --- a/docs/ref/databases.txt +++ b/docs/ref/databases.txt @@ -569,7 +569,8 @@ Row locking with ``QuerySet.select_for_update()`` MySQL does not support the ``NOWAIT`` and ``SKIP LOCKED`` options to the ``SELECT ... FOR UPDATE`` statement. If ``select_for_update()`` is used with -``nowait=True`` or ``skip_locked=True`` then a ``DatabaseError`` will be raised. +``nowait=True`` or ``skip_locked=True``, then a +:exc:`~django.db.NotSupportedError` is raised. Automatic typecasting can cause unexpected results -------------------------------------------------- diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index e98f0202ce..867ce47ce3 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -1640,8 +1640,8 @@ backends support ``select_for_update()``. However, MySQL doesn't support the ``nowait`` and ``skip_locked`` arguments. Passing ``nowait=True`` or ``skip_locked=True`` to ``select_for_update()`` -using database backends that do not support these options, such as MySQL, will -cause a :exc:`~django.db.DatabaseError` to be raised. This prevents code from +using database backends that do not support these options, such as MySQL, +raises a :exc:`~django.db.NotSupportedError`. This prevents code from unexpectedly blocking. Evaluating a queryset with ``select_for_update()`` in autocommit mode on diff --git a/tests/select_for_update/tests.py b/tests/select_for_update/tests.py index b36ff6114c..0c581f0f37 100644 --- a/tests/select_for_update/tests.py +++ b/tests/select_for_update/tests.py @@ -134,7 +134,7 @@ class SelectForUpdateTests(TransactionTestCase): @skipUnlessDBFeature('has_select_for_update') def test_unsupported_nowait_raises_error(self): """ - DatabaseError is raised if a SELECT...FOR UPDATE NOWAIT is run on + NotSupportedError is raised if a SELECT...FOR UPDATE NOWAIT is run on a database backend that supports FOR UPDATE but not NOWAIT. """ with self.assertRaisesMessage(NotSupportedError, 'NOWAIT is not supported on this database backend.'): @@ -145,8 +145,8 @@ class SelectForUpdateTests(TransactionTestCase): @skipUnlessDBFeature('has_select_for_update') def test_unsupported_skip_locked_raises_error(self): """ - DatabaseError is raised if a SELECT...FOR UPDATE SKIP LOCKED is run on - a database backend that supports FOR UPDATE but not SKIP LOCKED. + NotSupportedError is raised if a SELECT...FOR UPDATE SKIP LOCKED is run + on a database backend that supports FOR UPDATE but not SKIP LOCKED. """ with self.assertRaisesMessage(NotSupportedError, 'SKIP LOCKED is not supported on this database backend.'): with transaction.atomic(): @@ -189,7 +189,7 @@ class SelectForUpdateTests(TransactionTestCase): @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.' + msg = 'LIMIT/OFFSET is 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])