summaryrefslogtreecommitdiff
path: root/django/db/backends/mysql/schema.py
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2017-05-23 17:02:40 +0200
committerGitHub <noreply@github.com>2017-05-23 17:02:40 +0200
commit538bf43458a147b7edeb7118c9f325c3f59ff6fb (patch)
treea1724f358e8d8829c0c68b1e8bba6882d108fc53 /django/db/backends/mysql/schema.py
parentb3eb6eaf1a197ff155faf333871da032c77ba855 (diff)
downloaddjango-538bf43458a147b7edeb7118c9f325c3f59ff6fb.tar.gz
Fixed #27859 -- Ignored db_index for TextField/BinaryField on Oracle and MySQL.
Thanks Zubair Alam for the initial patch and Tim Graham for the review.
Diffstat (limited to 'django/db/backends/mysql/schema.py')
-rw-r--r--django/db/backends/mysql/schema.py20
1 files changed, 7 insertions, 13 deletions
diff --git a/django/db/backends/mysql/schema.py b/django/db/backends/mysql/schema.py
index 455fd1b0e3..9cae8b79b5 100644
--- a/django/db/backends/mysql/schema.py
+++ b/django/db/backends/mysql/schema.py
@@ -29,20 +29,12 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
import MySQLdb.converters
return MySQLdb.escape(value, MySQLdb.converters.conversions)
- def skip_default(self, field):
- """
- MySQL doesn't accept default values for some data types and implicitly
- treats these columns as nullable.
- """
+ def _is_limited_data_type(self, field):
db_type = field.db_type(self.connection)
- return (
- db_type is not None and
- db_type.lower() in {
- 'tinyblob', 'blob', 'mediumblob', 'longblob',
- 'tinytext', 'text', 'mediumtext', 'longtext',
- 'json',
- }
- )
+ return db_type is not None and db_type.lower() in self.connection._limited_data_types
+
+ def skip_default(self, field):
+ return self._is_limited_data_type(field)
def add_field(self, model, field):
super().add_field(model, field)
@@ -69,6 +61,8 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
field.get_internal_type() == 'ForeignKey' and
field.db_constraint):
return False
+ if self._is_limited_data_type(field):
+ return False
return create_index
def _delete_composed_index(self, model, fields, *args):