Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[py3] Prepared MySQL backend for Python 3 compatibility

  • Loading branch information...
commit bfc380baeaca359ac7b36eb35a2415e6a37e836c 1 parent 3fce0d2
Claude Paroz authored August 20, 2012
8  django/db/backends/mysql/compiler.py
... ...
@@ -1,10 +1,16 @@
  1
+try:
  2
+    from itertools import zip_longest
  3
+except ImportError:
  4
+    from itertools import izip_longest as zip_longest
  5
+
1 6
 from django.db.models.sql import compiler
2 7
 
  8
+
3 9
 class SQLCompiler(compiler.SQLCompiler):
4 10
     def resolve_columns(self, row, fields=()):
5 11
         values = []
6 12
         index_extra_select = len(self.query.extra_select)
7  
-        for value, field in map(None, row[index_extra_select:], fields):
  13
+        for value, field in zip_longest(row[index_extra_select:], fields):
8 14
             if (field and field.get_internal_type() in ("BooleanField", "NullBooleanField") and
9 15
                 value in (0, 1)):
10 16
                 value = bool(value)
7  django/db/backends/mysql/introspection.py
... ...
@@ -1,8 +1,9 @@
  1
+import re
  2
+from .base import FIELD_TYPE
  3
+
1 4
 from django.db.backends import BaseDatabaseIntrospection
2 5
 from django.utils import six
3  
-from MySQLdb import ProgrammingError, OperationalError
4  
-from MySQLdb.constants import FIELD_TYPE
5  
-import re
  6
+
6 7
 
7 8
 foreign_key_re = re.compile(r"\sCONSTRAINT `[^`]*` FOREIGN KEY \(`([^`]*)`\) REFERENCES `([^`]*)` \(`([^`]*)`\)")
8 9
 

0 notes on commit bfc380b

Please sign in to comment.
Something went wrong with that request. Please try again.