mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #27062 -- Eased implementing select_for_update() on MSSQL.
This commit is contained in:
parent
ef021412d5
commit
bae64dd0f1
3 changed files with 36 additions and 18 deletions
|
@ -5,9 +5,11 @@ import time
|
|||
|
||||
from multiple_database.routers import TestRouter
|
||||
|
||||
from django.db import DatabaseError, connection, router, transaction
|
||||
from django.db import (
|
||||
DatabaseError, connection, connections, router, transaction,
|
||||
)
|
||||
from django.test import (
|
||||
TransactionTestCase, override_settings, skipIfDBFeature,
|
||||
TransactionTestCase, mock, override_settings, skipIfDBFeature,
|
||||
skipUnlessDBFeature,
|
||||
)
|
||||
from django.test.utils import CaptureQueriesContext
|
||||
|
@ -150,6 +152,14 @@ class SelectForUpdateTests(TransactionTestCase):
|
|||
with transaction.atomic():
|
||||
Person.objects.select_for_update(skip_locked=True).get()
|
||||
|
||||
@skipUnlessDBFeature('has_select_for_update')
|
||||
def test_for_update_after_from(self):
|
||||
features_class = connections['default'].features.__class__
|
||||
attribute_to_patch = "%s.%s.for_update_after_from" % (features_class.__module__, features_class.__name__)
|
||||
with mock.patch(attribute_to_patch, return_value=True):
|
||||
with transaction.atomic():
|
||||
self.assertIn('FOR UPDATE WHERE', str(Person.objects.filter(name='foo').select_for_update().query))
|
||||
|
||||
@skipUnlessDBFeature('has_select_for_update')
|
||||
def test_for_update_requires_transaction(self):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue