Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[py3] Fixed Oracle specific failures

  • Loading branch information...
commit 4db38cbfe1087a51cd5d3d4fed9c7fcb952424d7 1 parent 9729f77
@akaariai akaariai authored
View
11 django/db/backends/oracle/base.py
@@ -221,7 +221,10 @@ def field_cast_sql(self, db_type):
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 @@ def __init__(self, param, cursor, strings_only=False):
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:
View
7 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 @@ def resolve_columns(self, row, fields=()):
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)
Please sign in to comment.
Something went wrong with that request. Please try again.