mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #34103 -- Fixed logging SQL queries with duplicate parameters on Oracle.
This commit is contained in:
parent
80c66e40f7
commit
64b3c413da
2 changed files with 25 additions and 8 deletions
|
@ -142,6 +142,23 @@ class LastExecutedQueryTest(TestCase):
|
|||
sql % params,
|
||||
)
|
||||
|
||||
def test_last_executed_query_with_duplicate_params(self):
|
||||
square_opts = Square._meta
|
||||
table = connection.introspection.identifier_converter(square_opts.db_table)
|
||||
id_column = connection.ops.quote_name(square_opts.get_field("id").column)
|
||||
root_column = connection.ops.quote_name(square_opts.get_field("root").column)
|
||||
sql = f"UPDATE {table} SET {root_column} = %s + %s WHERE {id_column} = %s"
|
||||
with connection.cursor() as cursor:
|
||||
params = [42, 42, 1]
|
||||
cursor.execute(sql, params)
|
||||
last_executed_query = connection.ops.last_executed_query(
|
||||
cursor, sql, params
|
||||
)
|
||||
self.assertEqual(
|
||||
last_executed_query,
|
||||
f"UPDATE {table} SET {root_column} = 42 + 42 WHERE {id_column} = 1",
|
||||
)
|
||||
|
||||
|
||||
class ParameterHandlingTest(TestCase):
|
||||
def test_bad_parameter_count(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue