diff options
| author | bakabiko <ahmedabt@gmail.com> | 2018-05-19 01:37:36 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-05-18 19:38:10 -0400 |
| commit | 54b29e022d14c2fee34c01a41f016d531bef5057 (patch) | |
| tree | 3c3f88275f53e94929cc7e7b0495c267f2a85384 /tests | |
| parent | 452abf7b43e4d93911e277976b87411bb4b2a52c (diff) | |
[2.1.x] Fixed #29380 -- Added support for QuerySet.select_for_update()'s nowait and skip_locked options on MySQL 8+.
Backport of a7bc1aea03508f544c9dfac0f34b01996653cef4 from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/backends/mysql/test_features.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/backends/mysql/test_features.py b/tests/backends/mysql/test_features.py index 65c897823b..51282792b3 100644 --- a/tests/backends/mysql/test_features.py +++ b/tests/backends/mysql/test_features.py @@ -1,6 +1,7 @@ from unittest import mock, skipUnless from django.db import connection +from django.db.backends.mysql.features import DatabaseFeatures from django.test import TestCase @@ -17,3 +18,15 @@ class TestFeatures(TestCase): with mock.patch('django.db.connection.features._mysql_storage_engine', 'MyISAM'): self.assertFalse(connection.features.supports_transactions) del connection.features.supports_transactions + + def test_skip_locked_no_wait(self): + with mock.MagicMock() as _connection: + _connection.mysql_version = (8, 0, 1) + database_features = DatabaseFeatures(_connection) + self.assertTrue(database_features.has_select_for_update_skip_locked) + self.assertTrue(database_features.has_select_for_update_nowait) + with mock.MagicMock() as _connection: + _connection.mysql_version = (8, 0, 0) + database_features = DatabaseFeatures(_connection) + self.assertFalse(database_features.has_select_for_update_skip_locked) + self.assertFalse(database_features.has_select_for_update_nowait) |
