Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion django/db/backends/oracle/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def last_executed_query(self, cursor, sql, params):
# Unlike Psycopg's `query` and MySQLdb`'s `_executed`, oracledb's
# `statement` doesn't contain the query parameters. Substitute
# parameters manually.
if params:
if statement and params:
if isinstance(params, (tuple, list)):
params = {
f":arg{i}": param for i, param in enumerate(dict.fromkeys(params))
Expand Down
6 changes: 6 additions & 0 deletions tests/backends/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,14 @@ def test_last_executed_query_without_previous_query(self):
last_executed_query should not raise an exception even if no previous
query has been run.
"""
suffix = connection.features.bare_select_suffix
with connection.cursor() as cursor:
if connection.vendor == "oracle":
cursor.statement = None
# No previous query has been run.
connection.ops.last_executed_query(cursor, "", ())
# Previous query crashed.
connection.ops.last_executed_query(cursor, "SELECT %s" + suffix, (1,))

def test_debug_sql(self):
qs = Reporter.objects.filter(first_name="test")
Expand Down
Loading