summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2020-03-19 09:42:04 +0100
committerGitHub <noreply@github.com>2020-03-19 09:42:04 +0100
commit6e026aec5fe24ebded360fbc40cff51ccb1f3901 (patch)
tree6b4bba11c1d54944da566492243f5ac02d58bb10
parentfc0fa72ff4cdbf5861a366e31cb8bbacd44da22d (diff)
Refs #29548 -- Mentioned MariaDB in database system checks.
-rw-r--r--django/db/backends/mysql/validation.py23
-rw-r--r--docs/ref/checks.txt10
-rw-r--r--tests/invalid_models_tests/test_ordinary_fields.py3
3 files changed, 23 insertions, 13 deletions
diff --git a/django/db/backends/mysql/validation.py b/django/db/backends/mysql/validation.py
index ee1c360e35..fc4dc500e1 100644
--- a/django/db/backends/mysql/validation.py
+++ b/django/db/backends/mysql/validation.py
@@ -12,12 +12,20 @@ class DatabaseValidation(BaseDatabaseValidation):
def _check_sql_mode(self, **kwargs):
if not (self.connection.sql_mode & {'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES'}):
return [checks.Warning(
- "MySQL Strict Mode is not set for database connection '%s'" % self.connection.alias,
- hint="MySQL's Strict Mode fixes many data integrity problems in MySQL, "
- "such as data truncation upon insertion, by escalating warnings into "
- "errors. It is strongly recommended you activate it. See: "
- "https://docs.djangoproject.com/en/%s/ref/databases/#mysql-sql-mode"
- % (get_docs_version(),),
+ "%s Strict Mode is not set for database connection '%s'"
+ % (self.connection.display_name, self.connection.alias),
+ hint=(
+ "%s's Strict Mode fixes many data integrity problems in "
+ "%s, such as data truncation upon insertion, by "
+ "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',
)]
return []
@@ -34,7 +42,8 @@ class DatabaseValidation(BaseDatabaseValidation):
(field.max_length is None or int(field.max_length) > 255)):
errors.append(
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,
id='mysql.E001',
)
diff --git a/docs/ref/checks.txt b/docs/ref/checks.txt
index 57c7b56fa9..5f9f9301ed 100644
--- a/docs/ref/checks.txt
+++ b/docs/ref/checks.txt
@@ -121,14 +121,14 @@ configured:
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.
-* **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`.
Model fields
diff --git a/tests/invalid_models_tests/test_ordinary_fields.py b/tests/invalid_models_tests/test_ordinary_fields.py
index c8b7e69634..8cfe41f0f1 100644
--- a/tests/invalid_models_tests/test_ordinary_fields.py
+++ b/tests/invalid_models_tests/test_ordinary_fields.py
@@ -373,7 +373,8 @@ class CharFieldTests(SimpleTestCase):
validator = DatabaseValidation(connection=connection)
self.assertEqual(validator.check_field(field), [
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,
id='mysql.E001',
)