diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2011-04-22 12:14:54 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2011-04-22 12:14:54 +0000 |
| commit | 5b0e4e49d4ab5e976fbfdde70c525a13220f3259 (patch) | |
| tree | 5e09c9c9eedefb8b0d815c0214afc09b4db76653 /django | |
| parent | 598032b8c4ec7d642b6223af8569bef81d183385 (diff) | |
Fixed #14091 - be more correct about logging queries in connection.queries.
Thanks to Aymeric Augustin for figuring out how to make this work across
multiple databases.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16081 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/backends/mysql/base.py | 6 | ||||
| -rw-r--r-- | django/db/backends/oracle/base.py | 5 | ||||
| -rw-r--r-- | django/db/backends/postgresql_psycopg2/operations.py | 5 |
3 files changed, 13 insertions, 3 deletions
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index 16067c6807..6d02aa771c 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -191,6 +191,12 @@ class DatabaseOperations(BaseDatabaseOperations): def fulltext_search_sql(self, field_name): return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name + def last_executed_query(self, cursor, sql, params): + # With MySQLdb, cursor objects have an (undocumented) "_last_executed" + # attribute where the exact query sent to the database is saved. + # See MySQLdb/cursors.py in the source distribution. + return cursor._last_executed + def no_limit_value(self): # 2**64 - 1, as recommended by the MySQL documentation return 18446744073709551615L diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index bcb906762b..c024e6d7d0 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -210,6 +210,11 @@ WHEN (new.%(col_name)s IS NULL) else: return "%s" + 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 + def last_insert_id(self, cursor, table_name, pk_name): sq_name = self._get_sequence_name(table_name) cursor.execute('SELECT "%s".currval FROM dual' % sq_name) diff --git a/django/db/backends/postgresql_psycopg2/operations.py b/django/db/backends/postgresql_psycopg2/operations.py index 4efdb8fa3e..33159133d6 100644 --- a/django/db/backends/postgresql_psycopg2/operations.py +++ b/django/db/backends/postgresql_psycopg2/operations.py @@ -202,9 +202,8 @@ class DatabaseOperations(BaseDatabaseOperations): return 63 def last_executed_query(self, cursor, sql, params): - # With psycopg2, cursor objects have a "query" attribute that is the - # exact query sent to the database. See docs here: - # http://www.initd.org/tracker/psycopg/wiki/psycopg2_documentation#postgresql-status-message-and-executed-query + # http://initd.org/psycopg/docs/cursor.html#cursor.query + # The query attribute is a Psycopg extension to the DB API 2.0. return cursor.query def return_insert_id(self): |
