Commit 4db38cbf authored by Anssi Kääriäinen's avatar Anssi Kääriäinen
Browse files

[py3] Fixed Oracle specific failures

parent 9729f773
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -221,6 +221,9 @@ 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.
        if six.PY3:
            return cursor.statement
        else:
            return cursor.statement.decode("utf-8")

    def last_insert_id(self, cursor, table_name, pk_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:
+6 −1
Original line number Diff line number Diff line
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)