mirror of https://github.com/django/django.git
Fixed #31271 -- Preserved ordering when unifying query parameters on Oracle.
This caused misplacing parameters in logged SQL queries.
Regression in 79065b55a7
.
Thanks Hans Aarne Liblik for the report.
This commit is contained in:
parent
cbb6531e5b
commit
2a038521c4
|
@ -500,7 +500,10 @@ class FormatStylePlaceholderCursor:
|
||||||
# params_dict = {0.75: ':arg0', 2: ':arg1', 'sth': ':arg2'}
|
# params_dict = {0.75: ':arg0', 2: ':arg1', 'sth': ':arg2'}
|
||||||
# args = [':arg0', ':arg1', ':arg0', ':arg2', ':arg0']
|
# args = [':arg0', ':arg1', ':arg0', ':arg2', ':arg0']
|
||||||
# params = {':arg0': 0.75, ':arg1': 2, ':arg2': 'sth'}
|
# params = {':arg0': 0.75, ':arg1': 2, ':arg2': 'sth'}
|
||||||
params_dict = {param: ':arg%d' % i for i, param in enumerate(set(params))}
|
params_dict = {
|
||||||
|
param: ':arg%d' % i
|
||||||
|
for i, param in enumerate(dict.fromkeys(params))
|
||||||
|
}
|
||||||
args = [params_dict[param] for param in params]
|
args = [params_dict[param] for param in params]
|
||||||
params = {value: key for key, value in params_dict.items()}
|
params = {value: key for key, value in params_dict.items()}
|
||||||
query = query % tuple(args)
|
query = query % tuple(args)
|
||||||
|
|
|
@ -20,3 +20,6 @@ Bugfixes
|
||||||
related fields or parent link fields with :ref:`multi-table-inheritance` in
|
related fields or parent link fields with :ref:`multi-table-inheritance` in
|
||||||
the ``of`` argument, the corresponding models were not locked
|
the ``of`` argument, the corresponding models were not locked
|
||||||
(:ticket:`31246`).
|
(:ticket:`31246`).
|
||||||
|
|
||||||
|
* Fixed a regression in Django 3.0 that caused misplacing parameters in logged
|
||||||
|
SQL queries on Oracle (:ticket:`31271`).
|
||||||
|
|
|
@ -79,6 +79,10 @@ class LastExecutedQueryTest(TestCase):
|
||||||
for qs in (
|
for qs in (
|
||||||
Article.objects.filter(pk=1),
|
Article.objects.filter(pk=1),
|
||||||
Article.objects.filter(pk__in=(1, 2), reporter__pk=3),
|
Article.objects.filter(pk__in=(1, 2), reporter__pk=3),
|
||||||
|
Article.objects.filter(
|
||||||
|
pk=1,
|
||||||
|
reporter__pk=9,
|
||||||
|
).exclude(reporter__pk__in=[2, 1]),
|
||||||
):
|
):
|
||||||
sql, params = qs.query.sql_with_params()
|
sql, params = qs.query.sql_with_params()
|
||||||
with qs.query.get_compiler(DEFAULT_DB_ALIAS).execute_sql(CURSOR) as cursor:
|
with qs.query.get_compiler(DEFAULT_DB_ALIAS).execute_sql(CURSOR) as cursor:
|
||||||
|
|
Loading…
Reference in New Issue