summaryrefslogtreecommitdiff
path: root/django/db/backends/mysql
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/backends/mysql')
-rw-r--r--django/db/backends/mysql/base.py13
-rw-r--r--django/db/backends/mysql/client.py2
-rw-r--r--django/db/backends/mysql/compiler.py6
-rw-r--r--django/db/backends/mysql/creation.py37
-rw-r--r--django/db/backends/mysql/introspection.py2
-rw-r--r--django/db/backends/mysql/validation.py1
6 files changed, 38 insertions, 23 deletions
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index d10be94f43..2db746f40f 100644
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -36,8 +36,9 @@ except ImportError:
pytz = None
from django.conf import settings
-from django.db import utils
-from django.db.backends import *
+from django.db import (utils, BaseDatabaseFeatures, BaseDatabaseOperations,
+ BaseDatabaseWrapper)
+from django.db.backends import util
from django.db.backends.mysql.client import DatabaseClient
from django.db.backends.mysql.creation import DatabaseCreation
from django.db.backends.mysql.introspection import DatabaseIntrospection
@@ -57,6 +58,7 @@ IntegrityError = Database.IntegrityError
# It's impossible to import datetime_or_None directly from MySQLdb.times
parse_datetime = conversions[FIELD_TYPE.DATETIME]
+
def parse_datetime_with_timezone_support(value):
dt = parse_datetime(value)
# Confirm that dt is naive before overwriting its tzinfo.
@@ -64,6 +66,7 @@ def parse_datetime_with_timezone_support(value):
dt = dt.replace(tzinfo=timezone.utc)
return dt
+
def adapt_datetime_with_timezone_support(value, conv):
# Equivalent to DateTimeField.get_db_prep_value. Used only by raw SQL.
if settings.USE_TZ:
@@ -98,6 +101,7 @@ django_conversions.update({
# http://dev.mysql.com/doc/refman/5.0/en/news.html .
server_version_re = re.compile(r'(\d{1,2})\.(\d{1,2})\.(\d{1,2})')
+
# MySQLdb-1.2.1 and newer automatically makes use of SHOW WARNINGS on
# MySQL-4.1 and newer, so the MysqlDebugWrapper is unnecessary. Since the
# point is to raise Warnings as exceptions, this can be done with the Python
@@ -148,6 +152,7 @@ class CursorWrapper(object):
def __iter__(self):
return iter(self.cursor)
+
class DatabaseFeatures(BaseDatabaseFeatures):
empty_fetchmany_value = ()
update_can_self_select = False
@@ -204,6 +209,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
cursor.execute("SELECT 1 FROM mysql.time_zone LIMIT 1")
return cursor.fetchone() is not None
+
class DatabaseOperations(BaseDatabaseOperations):
compiler_module = "django.db.backends.mysql.compiler"
@@ -319,7 +325,7 @@ class DatabaseOperations(BaseDatabaseOperations):
# Truncate already resets the AUTO_INCREMENT field from
# MySQL version 5.0.13 onwards. Refs #16961.
if self.connection.mysql_version < (5, 0, 13):
- return ["%s %s %s %s %s;" % \
+ return ["%s %s %s %s %s;" %
(style.SQL_KEYWORD('ALTER'),
style.SQL_KEYWORD('TABLE'),
style.SQL_TABLE(self.quote_name(sequence['table'])),
@@ -373,6 +379,7 @@ class DatabaseOperations(BaseDatabaseOperations):
items_sql = "(%s)" % ", ".join(["%s"] * len(fields))
return "VALUES " + ", ".join([items_sql] * num_values)
+
class DatabaseWrapper(BaseDatabaseWrapper):
vendor = 'mysql'
operators = {
diff --git a/django/db/backends/mysql/client.py b/django/db/backends/mysql/client.py
index 1cf8ceef9c..8364c7b6e6 100644
--- a/django/db/backends/mysql/client.py
+++ b/django/db/backends/mysql/client.py
@@ -3,6 +3,7 @@ import sys
from django.db.backends import BaseDatabaseClient
+
class DatabaseClient(BaseDatabaseClient):
executable_name = 'mysql'
@@ -37,4 +38,3 @@ class DatabaseClient(BaseDatabaseClient):
sys.exit(os.system(" ".join(args)))
else:
os.execvp(self.executable_name, args)
-
diff --git a/django/db/backends/mysql/compiler.py b/django/db/backends/mysql/compiler.py
index 4e033e3d93..b7d1d7b98d 100644
--- a/django/db/backends/mysql/compiler.py
+++ b/django/db/backends/mysql/compiler.py
@@ -22,20 +22,26 @@ class SQLCompiler(compiler.SQLCompiler):
sql, params = self.as_sql()
return '(%s) IN (%s)' % (', '.join(['%s.%s' % (qn(alias), qn2(column)) for column in columns]), sql), params
+
class SQLInsertCompiler(compiler.SQLInsertCompiler, SQLCompiler):
pass
+
class SQLDeleteCompiler(compiler.SQLDeleteCompiler, SQLCompiler):
pass
+
class SQLUpdateCompiler(compiler.SQLUpdateCompiler, SQLCompiler):
pass
+
class SQLAggregateCompiler(compiler.SQLAggregateCompiler, SQLCompiler):
pass
+
class SQLDateCompiler(compiler.SQLDateCompiler, SQLCompiler):
pass
+
class SQLDateTimeCompiler(compiler.SQLDateTimeCompiler, SQLCompiler):
pass
diff --git a/django/db/backends/mysql/creation.py b/django/db/backends/mysql/creation.py
index 3a57c29479..b59b225f4f 100644
--- a/django/db/backends/mysql/creation.py
+++ b/django/db/backends/mysql/creation.py
@@ -1,34 +1,35 @@
from django.db.backends.creation import BaseDatabaseCreation
+
class DatabaseCreation(BaseDatabaseCreation):
# This dictionary maps Field objects to their associated MySQL column
# types, as strings. Column-type strings can contain format strings; they'll
# be interpolated against the values of Field.__dict__ before being output.
# If a column type is set to None, it won't be included in the output.
data_types = {
- 'AutoField': 'integer AUTO_INCREMENT',
- 'BinaryField': 'longblob',
- 'BooleanField': 'bool',
- 'CharField': 'varchar(%(max_length)s)',
+ 'AutoField': 'integer AUTO_INCREMENT',
+ 'BinaryField': 'longblob',
+ 'BooleanField': 'bool',
+ 'CharField': 'varchar(%(max_length)s)',
'CommaSeparatedIntegerField': 'varchar(%(max_length)s)',
- 'DateField': 'date',
- 'DateTimeField': 'datetime',
- 'DecimalField': 'numeric(%(max_digits)s, %(decimal_places)s)',
- 'FileField': 'varchar(%(max_length)s)',
- 'FilePathField': 'varchar(%(max_length)s)',
- 'FloatField': 'double precision',
- 'IntegerField': 'integer',
- 'BigIntegerField': 'bigint',
- 'IPAddressField': 'char(15)',
+ 'DateField': 'date',
+ 'DateTimeField': 'datetime',
+ 'DecimalField': 'numeric(%(max_digits)s, %(decimal_places)s)',
+ 'FileField': 'varchar(%(max_length)s)',
+ 'FilePathField': 'varchar(%(max_length)s)',
+ 'FloatField': 'double precision',
+ 'IntegerField': 'integer',
+ 'BigIntegerField': 'bigint',
+ 'IPAddressField': 'char(15)',
'GenericIPAddressField': 'char(39)',
- 'NullBooleanField': 'bool',
- 'OneToOneField': 'integer',
+ 'NullBooleanField': 'bool',
+ 'OneToOneField': 'integer',
'PositiveIntegerField': 'integer UNSIGNED',
'PositiveSmallIntegerField': 'smallint UNSIGNED',
- 'SlugField': 'varchar(%(max_length)s)',
+ 'SlugField': 'varchar(%(max_length)s)',
'SmallIntegerField': 'smallint',
- 'TextField': 'longtext',
- 'TimeField': 'time',
+ 'TextField': 'longtext',
+ 'TimeField': 'time',
}
def sql_table_creation_suffix(self):
diff --git a/django/db/backends/mysql/introspection.py b/django/db/backends/mysql/introspection.py
index 548877e8e6..ec9f3e99f8 100644
--- a/django/db/backends/mysql/introspection.py
+++ b/django/db/backends/mysql/introspection.py
@@ -7,6 +7,7 @@ from django.utils.encoding import force_text
foreign_key_re = re.compile(r"\sCONSTRAINT `[^`]*` FOREIGN KEY \(`([^`]*)`\) REFERENCES `([^`]*)` \(`([^`]*)`\)")
+
class DatabaseIntrospection(BaseDatabaseIntrospection):
data_types_reverse = {
FIELD_TYPE.BLOB: 'TextField',
@@ -116,4 +117,3 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
continue
indexes[row[4]] = {'primary_key': (row[2] == 'PRIMARY'), 'unique': not bool(row[1])}
return indexes
-
diff --git a/django/db/backends/mysql/validation.py b/django/db/backends/mysql/validation.py
index 2ce957cce7..17b7cde756 100644
--- a/django/db/backends/mysql/validation.py
+++ b/django/db/backends/mysql/validation.py
@@ -1,5 +1,6 @@
from django.db.backends import BaseDatabaseValidation
+
class DatabaseValidation(BaseDatabaseValidation):
def validate_field(self, errors, opts, f):
"""