mirror of
https://github.com/django/django.git
synced 2025-07-06 10:49:17 +00:00
[5.2.x] Fixed #36111 -- Fixed test --debug-sql crash on Oracle when no prior query has executed.
Backport of 330d89d4fe7832355535580383523f1749a3ee45 from main
This commit is contained in:
parent
93e18a87dd
commit
e9576c0aa8
@ -328,7 +328,7 @@ END;
|
|||||||
# Unlike Psycopg's `query` and MySQLdb`'s `_executed`, oracledb's
|
# Unlike Psycopg's `query` and MySQLdb`'s `_executed`, oracledb's
|
||||||
# `statement` doesn't contain the query parameters. Substitute
|
# `statement` doesn't contain the query parameters. Substitute
|
||||||
# parameters manually.
|
# parameters manually.
|
||||||
if params:
|
if statement and params:
|
||||||
if isinstance(params, (tuple, list)):
|
if isinstance(params, (tuple, list)):
|
||||||
params = {
|
params = {
|
||||||
f":arg{i}": param for i, param in enumerate(dict.fromkeys(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
|
last_executed_query should not raise an exception even if no previous
|
||||||
query has been run.
|
query has been run.
|
||||||
"""
|
"""
|
||||||
|
suffix = connection.features.bare_select_suffix
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
|
if connection.vendor == "oracle":
|
||||||
|
cursor.statement = None
|
||||||
|
# No previous query has been run.
|
||||||
connection.ops.last_executed_query(cursor, "", ())
|
connection.ops.last_executed_query(cursor, "", ())
|
||||||
|
# Previous query crashed.
|
||||||
|
connection.ops.last_executed_query(cursor, "SELECT %s" + suffix, (1,))
|
||||||
|
|
||||||
def test_debug_sql(self):
|
def test_debug_sql(self):
|
||||||
list(Reporter.objects.filter(first_name="test"))
|
list(Reporter.objects.filter(first_name="test"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user