mirror of
https://github.com/django/django.git
synced 2025-11-20 03:30:00 +00:00
Fixed #36111 -- Fixed test --debug-sql crash on Oracle when no prior query has executed.
This commit is contained in:
parent
9cc3970eaa
commit
330d89d4fe
2 changed files with 7 additions and 1 deletions
|
|
@ -319,7 +319,7 @@ END;
|
|||
# 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))
|
||||
|
|
|
|||
|
|
@ -73,8 +73,14 @@ class LastExecutedQueryTest(TestCase):
|
|||
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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue