summaryrefslogtreecommitdiff
path: root/tests/backends
diff options
context:
space:
mode:
authorDavid Sanders <shang.xiao.sanders@gmail.com>2022-10-18 23:13:18 +1100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-11-25 09:42:25 +0100
commit64b3c413da011f55469165256261f406a277e822 (patch)
tree10f018d91a8d7ac011fcd29f3f34f188bf2ad782 /tests/backends
parent80c66e40f7beecbd5ee501f757a2e61236597349 (diff)
downloaddjango-64b3c413da011f55469165256261f406a277e822.tar.gz
Fixed #34103 -- Fixed logging SQL queries with duplicate parameters on Oracle.
Diffstat (limited to 'tests/backends')
-rw-r--r--tests/backends/tests.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/backends/tests.py b/tests/backends/tests.py
index c6980058ca..c3cfa61fdb 100644
--- a/tests/backends/tests.py
+++ b/tests/backends/tests.py
@@ -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):