Ticket #20010: 0001-Fixed-20010-Make-sure-last_executed_query-contains-i.patch

File 0001-Fixed-20010-Make-sure-last_executed_query-contains-i.patch, 2.4 KB (added by Simon Charette, 12 years ago)
  • django/db/backends/oracle/base.py

    From b37b7b526bb55d389cd77caa8eb6878cb66fc0c2 Mon Sep 17 00:00:00 2001
    From: Simon Charette <charette.s@gmail.com>
    Date: Sun, 10 Mar 2013 22:50:18 -0400
    Subject: [PATCH] Fixed #20010 -- Make sure `last_executed_query` contains
     it's associated parameters on Oracle.
    
    Also removed some unused imports.
    ---
     django/db/backends/oracle/base.py |   17 +++++++----------
     1 file changed, 7 insertions(+), 10 deletions(-)
    
    diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
    index 60ee1ba..56414d1 100644
    a b Requires cx_Oracle: http://cx-oracle.sourceforge.net/  
    55"""
    66from __future__ import unicode_literals
    77
    8 import datetime
    98import decimal
    109import re
    1110import sys
    except ImportError as e:  
    4544    from django.core.exceptions import ImproperlyConfigured
    4645    raise ImproperlyConfigured("Error loading cx_Oracle module: %s" % e)
    4746
    48 from django.conf import settings
    4947from django.db import utils
    5048from django.db.backends import *
    5149from django.db.backends.oracle.client import DatabaseClient
    5250from django.db.backends.oracle.creation import DatabaseCreation
    5351from django.db.backends.oracle.introspection import DatabaseIntrospection
    5452from django.utils.encoding import force_bytes, force_text
    55 from django.utils.functional import cached_property
    56 from django.utils import six
    57 from django.utils import timezone
     53
    5854
    5955DatabaseError = Database.DatabaseError
    6056IntegrityError = Database.IntegrityError
    WHEN (new.%(col_name)s IS NULL)  
    267263    def last_executed_query(self, cursor, sql, params):
    268264        # http://cx-oracle.sourceforge.net/html/cursor.html#Cursor.statement
    269265        # The DB API definition does not define this attribute.
    270         if six.PY3:
    271             return cursor.statement
    272         else:
    273             query = cursor.statement
    274             return query if isinstance(query, unicode) else query.decode("utf-8")
     266        statement = cursor.statement
     267        if not six.PY3 and not isinstance(statement, unicode):
     268            statement = statement.decode('utf-8')
     269        # Unlike Psycopg's `query` and MySQLdb`'s `_last_executed`, CxOracle's
     270        # `statement` doesn't contain the query parameters. refs #20010.
     271        return super(DatabaseOperations, self).last_executed_query(cursor, statement, params)
    275272
    276273    def last_insert_id(self, cursor, table_name, pk_name):
    277274        sq_name = self._get_sequence_name(table_name)
Back to Top