diff options
| author | Claude Paroz <claude@2xlibre.net> | 2012-08-20 10:46:21 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2012-08-20 10:46:21 +0200 |
| commit | bfc380baeaca359ac7b36eb35a2415e6a37e836c (patch) | |
| tree | 1946d9761dfaa5cc7e7389f73f787eba5c7db5b1 | |
| parent | 3fce0d2a9162cf6e749a6de0b18890dea8955e89 (diff) | |
[py3] Prepared MySQL backend for Python 3 compatibility
| -rw-r--r-- | django/db/backends/mysql/compiler.py | 8 | ||||
| -rw-r--r-- | django/db/backends/mysql/introspection.py | 7 |
2 files changed, 11 insertions, 4 deletions
diff --git a/django/db/backends/mysql/compiler.py b/django/db/backends/mysql/compiler.py index 012bca5da6..d8e9b3a202 100644 --- a/django/db/backends/mysql/compiler.py +++ b/django/db/backends/mysql/compiler.py @@ -1,10 +1,16 @@ +try: + from itertools import zip_longest +except ImportError: + from itertools import izip_longest as zip_longest + from django.db.models.sql import compiler + class SQLCompiler(compiler.SQLCompiler): def resolve_columns(self, row, fields=()): values = [] index_extra_select = len(self.query.extra_select) - for value, field in map(None, row[index_extra_select:], fields): + for value, field in zip_longest(row[index_extra_select:], fields): if (field and field.get_internal_type() in ("BooleanField", "NullBooleanField") and value in (0, 1)): value = bool(value) diff --git a/django/db/backends/mysql/introspection.py b/django/db/backends/mysql/introspection.py index 6aab0b99ab..041fbee1b2 100644 --- a/django/db/backends/mysql/introspection.py +++ b/django/db/backends/mysql/introspection.py @@ -1,8 +1,9 @@ +import re +from .base import FIELD_TYPE + from django.db.backends import BaseDatabaseIntrospection from django.utils import six -from MySQLdb import ProgrammingError, OperationalError -from MySQLdb.constants import FIELD_TYPE -import re + foreign_key_re = re.compile(r"\sCONSTRAINT `[^`]*` FOREIGN KEY \(`([^`]*)`\) REFERENCES `([^`]*)` \(`([^`]*)`\)") |
