summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2012-08-19 21:15:52 +0300
committerAnssi Kääriäinen <akaariai@gmail.com>2012-08-19 23:45:26 +0300
commit4db38cbfe1087a51cd5d3d4fed9c7fcb952424d7 (patch)
tree54f00ba8a506daf1fa3f8292e45669787fc1ce41
parent9729f77326af9f6dc8644ec2574a2c356f84f32d (diff)
[py3] Fixed Oracle specific failures
-rw-r--r--django/db/backends/oracle/base.py11
-rw-r--r--django/db/backends/oracle/compiler.py7
2 files changed, 16 insertions, 2 deletions
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index 89cad12b6c..7d4f2b445a 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -221,7 +221,10 @@ WHEN (new.%(col_name)s IS NULL)
def last_executed_query(self, cursor, sql, params):
# http://cx-oracle.sourceforge.net/html/cursor.html#Cursor.statement
# The DB API definition does not define this attribute.
- return cursor.statement.decode("utf-8")
+ if six.PY3:
+ return cursor.statement
+ else:
+ return cursor.statement.decode("utf-8")
def last_insert_id(self, cursor, table_name, pk_name):
sq_name = self._get_sequence_name(table_name)
@@ -594,6 +597,12 @@ class OracleParam(object):
param = timezone.make_aware(param, default_timezone)
param = param.astimezone(timezone.utc).replace(tzinfo=None)
+ # Oracle doesn't recognize True and False correctly in Python 3.
+ # The conversion done below works both in 2 and 3.
+ if param is True:
+ param = "1"
+ elif param is False:
+ param = "0"
if hasattr(param, 'bind_parameter'):
self.smart_bytes = param.bind_parameter(cursor)
else:
diff --git a/django/db/backends/oracle/compiler.py b/django/db/backends/oracle/compiler.py
index e21f867f82..24030cdffc 100644
--- a/django/db/backends/oracle/compiler.py
+++ b/django/db/backends/oracle/compiler.py
@@ -1,4 +1,9 @@
from django.db.models.sql import compiler
+# The izip_longest was renamed to zip_longest in py3
+try:
+ from itertools import zip_longest
+except ImportError:
+ from itertools import izip_longest as zip_longest
class SQLCompiler(compiler.SQLCompiler):
@@ -13,7 +18,7 @@ class SQLCompiler(compiler.SQLCompiler):
index_start = rn_offset + len(self.query.extra_select)
values = [self.query.convert_values(v, None, connection=self.connection)
for v in row[rn_offset:index_start]]
- for value, field in map(None, row[index_start:], fields):
+ for value, field in zip_longest(row[index_start:], fields):
values.append(self.query.convert_values(value, field, connection=self.connection))
return tuple(values)