diff options
Diffstat (limited to 'django/db/backends/mysql/operations.py')
-rw-r--r-- | django/db/backends/mysql/operations.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/django/db/backends/mysql/operations.py b/django/db/backends/mysql/operations.py index ffddb64e3c..05523fcdbe 100644 --- a/django/db/backends/mysql/operations.py +++ b/django/db/backends/mysql/operations.py @@ -227,8 +227,9 @@ class DatabaseOperations(BaseDatabaseOperations): ] def validate_autopk_value(self, value): - # MySQLism: zero in AUTO_INCREMENT field does not work. Refs #17653. - if value == 0: + # Zero in AUTO_INCREMENT field does not work without the + # NO_AUTO_VALUE_ON_ZERO SQL mode. + if value == 0 and not self.connection.features.allows_auto_pk_0: raise ValueError('The database backend does not accept 0 as a ' 'value for AutoField.') return value @@ -266,6 +267,9 @@ class DatabaseOperations(BaseDatabaseOperations): def max_name_length(self): return 64 + def pk_default_value(self): + return 'NULL' + def bulk_insert_sql(self, fields, placeholder_rows): placeholder_rows_sql = (", ".join(row) for row in placeholder_rows) values_sql = ", ".join("(%s)" % sql for sql in placeholder_rows_sql) |