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 /django/db/backends/mysql/features.py | |
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 'django/db/backends/mysql/features.py')
-rw-r--r-- | django/db/backends/mysql/features.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/django/db/backends/mysql/features.py b/django/db/backends/mysql/features.py index d4651516fe..e55d098057 100644 --- a/django/db/backends/mysql/features.py +++ b/django/db/backends/mysql/features.py @@ -17,7 +17,6 @@ class DatabaseFeatures(BaseDatabaseFeatures): supports_index_column_ordering = False supports_timezones = False requires_explicit_null_ordering_when_grouping = True - allows_auto_pk_0 = False can_release_savepoints = True atomic_transactions = False can_clone_databases = True @@ -52,6 +51,14 @@ class DatabaseFeatures(BaseDatabaseFeatures): return self.connection.mysql_server_data['default_storage_engine'] @cached_property + def allows_auto_pk_0(self): + """ + Autoincrement primary key can be set to 0 if it doesn't generate new + autoincrement values. + """ + return 'NO_AUTO_VALUE_ON_ZERO' in self.connection.sql_mode + + @cached_property def update_can_self_select(self): return self.connection.mysql_is_mariadb and self.connection.mysql_version >= (10, 3, 2) |