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/
|
5 | 5 | """ |
6 | 6 | from __future__ import unicode_literals |
7 | 7 | |
8 | | import datetime |
9 | 8 | import decimal |
10 | 9 | import re |
11 | 10 | import sys |
… |
… |
except ImportError as e:
|
45 | 44 | from django.core.exceptions import ImproperlyConfigured |
46 | 45 | raise ImproperlyConfigured("Error loading cx_Oracle module: %s" % e) |
47 | 46 | |
48 | | from django.conf import settings |
49 | 47 | from django.db import utils |
50 | 48 | from django.db.backends import * |
51 | 49 | from django.db.backends.oracle.client import DatabaseClient |
52 | 50 | from django.db.backends.oracle.creation import DatabaseCreation |
53 | 51 | from django.db.backends.oracle.introspection import DatabaseIntrospection |
54 | 52 | from 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 | |
58 | 54 | |
59 | 55 | DatabaseError = Database.DatabaseError |
60 | 56 | IntegrityError = Database.IntegrityError |
… |
… |
WHEN (new.%(col_name)s IS NULL)
|
267 | 263 | def last_executed_query(self, cursor, sql, params): |
268 | 264 | # http://cx-oracle.sourceforge.net/html/cursor.html#Cursor.statement |
269 | 265 | # 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) |
275 | 272 | |
276 | 273 | def last_insert_id(self, cursor, table_name, pk_name): |
277 | 274 | sq_name = self._get_sequence_name(table_name) |