Refs #29548 -- Mentioned MariaDB in database system checks.
This commit is contained in:
parent
fc0fa72ff4
commit
6e026aec5f
|
@ -12,12 +12,20 @@ class DatabaseValidation(BaseDatabaseValidation):
|
||||||
def _check_sql_mode(self, **kwargs):
|
def _check_sql_mode(self, **kwargs):
|
||||||
if not (self.connection.sql_mode & {'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES'}):
|
if not (self.connection.sql_mode & {'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES'}):
|
||||||
return [checks.Warning(
|
return [checks.Warning(
|
||||||
"MySQL Strict Mode is not set for database connection '%s'" % self.connection.alias,
|
"%s Strict Mode is not set for database connection '%s'"
|
||||||
hint="MySQL's Strict Mode fixes many data integrity problems in MySQL, "
|
% (self.connection.display_name, self.connection.alias),
|
||||||
"such as data truncation upon insertion, by escalating warnings into "
|
hint=(
|
||||||
"errors. It is strongly recommended you activate it. See: "
|
"%s's Strict Mode fixes many data integrity problems in "
|
||||||
"https://docs.djangoproject.com/en/%s/ref/databases/#mysql-sql-mode"
|
"%s, such as data truncation upon insertion, by "
|
||||||
% (get_docs_version(),),
|
"escalating warnings into errors. It is strongly "
|
||||||
|
"recommended you activate it. See: "
|
||||||
|
"https://docs.djangoproject.com/en/%s/ref/databases/#mysql-sql-mode"
|
||||||
|
% (
|
||||||
|
self.connection.display_name,
|
||||||
|
self.connection.display_name,
|
||||||
|
get_docs_version(),
|
||||||
|
),
|
||||||
|
),
|
||||||
id='mysql.W002',
|
id='mysql.W002',
|
||||||
)]
|
)]
|
||||||
return []
|
return []
|
||||||
|
@ -34,7 +42,8 @@ class DatabaseValidation(BaseDatabaseValidation):
|
||||||
(field.max_length is None or int(field.max_length) > 255)):
|
(field.max_length is None or int(field.max_length) > 255)):
|
||||||
errors.append(
|
errors.append(
|
||||||
checks.Error(
|
checks.Error(
|
||||||
'MySQL does not allow unique CharFields to have a max_length > 255.',
|
'%s does not allow unique CharFields to have a max_length '
|
||||||
|
'> 255.' % self.connection.display_name,
|
||||||
obj=field,
|
obj=field,
|
||||||
id='mysql.E001',
|
id='mysql.E001',
|
||||||
)
|
)
|
||||||
|
|
|
@ -121,14 +121,14 @@ configured:
|
||||||
Database
|
Database
|
||||||
--------
|
--------
|
||||||
|
|
||||||
MySQL
|
MySQL and MariaDB
|
||||||
~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
If you're using MySQL, the following checks will be performed:
|
If you're using MySQL or MariaDB, the following checks will be performed:
|
||||||
|
|
||||||
* **mysql.E001**: MySQL does not allow unique ``CharField``\s to have a
|
* **mysql.E001**: MySQL/MariaDB does not allow unique ``CharField``\s to have a
|
||||||
``max_length`` > 255.
|
``max_length`` > 255.
|
||||||
* **mysql.W002**: MySQL Strict Mode is not set for database connection
|
* **mysql.W002**: MySQL/MariaDB Strict Mode is not set for database connection
|
||||||
'<alias>'. See also :ref:`mysql-sql-mode`.
|
'<alias>'. See also :ref:`mysql-sql-mode`.
|
||||||
|
|
||||||
Model fields
|
Model fields
|
||||||
|
|
|
@ -373,7 +373,8 @@ class CharFieldTests(SimpleTestCase):
|
||||||
validator = DatabaseValidation(connection=connection)
|
validator = DatabaseValidation(connection=connection)
|
||||||
self.assertEqual(validator.check_field(field), [
|
self.assertEqual(validator.check_field(field), [
|
||||||
Error(
|
Error(
|
||||||
'MySQL does not allow unique CharFields to have a max_length > 255.',
|
'%s does not allow unique CharFields to have a max_length > '
|
||||||
|
'255.' % connection.display_name,
|
||||||
obj=field,
|
obj=field,
|
||||||
id='mysql.E001',
|
id='mysql.E001',
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue