diff options
author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-07-20 09:48:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-20 09:48:31 +0200 |
commit | 83f55aafdd635189c010cff403f66b54d695921a (patch) | |
tree | ba3f3244e4300bc055555f7693363f28fa885169 /tests/backends | |
parent | 730711e8282893723f993f55d3e3b0c823cfdb9a (diff) | |
download | django-83f55aafdd635189c010cff403f66b54d695921a.tar.gz |
Fixed #17653 -- Allowed using zero as AutoFields value on MySQL if NO_AUTO_VALUE_ON_ZERO SQL mode is enabled.
Diffstat (limited to 'tests/backends')
-rw-r--r-- | tests/backends/mysql/test_features.py | 6 | ||||
-rw-r--r-- | tests/backends/tests.py | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/tests/backends/mysql/test_features.py b/tests/backends/mysql/test_features.py index 1385c9b88c..5d27890a5d 100644 --- a/tests/backends/mysql/test_features.py +++ b/tests/backends/mysql/test_features.py @@ -32,3 +32,9 @@ class TestFeatures(TestCase): database_features = DatabaseFeatures(_connection) self.assertFalse(database_features.has_select_for_update_skip_locked) self.assertFalse(database_features.has_select_for_update_nowait) + + def test_allows_auto_pk_0(self): + with mock.MagicMock() as _connection: + _connection.sql_mode = {'NO_AUTO_VALUE_ON_ZERO'} + database_features = DatabaseFeatures(_connection) + self.assertIs(database_features.allows_auto_pk_0, True) diff --git a/tests/backends/tests.py b/tests/backends/tests.py index 08bdac3437..cf6bdbf25d 100644 --- a/tests/backends/tests.py +++ b/tests/backends/tests.py @@ -806,7 +806,8 @@ class ThreadTests(TransactionTestCase): class MySQLPKZeroTests(TestCase): """ Zero as id for AutoField should raise exception in MySQL, because MySQL - does not allow zero for autoincrement primary key. + does not allow zero for autoincrement primary key if the + NO_AUTO_VALUE_ON_ZERO SQL mode is not enabled. """ @skipIfDBFeature('allows_auto_pk_0') def test_zero_as_autoval(self): |