﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
31271	Logged queries may interpolate parameters in the wrong order on Oracle.	Hans Aarne Liblik	Mariusz Felisiak	"When making a query 

{{{
MyObject.objects.filter(field1='value1').exclude(field2__in=['badValue1', 'badValue2'])
}}}

{{{
django/db/backends/oracle/base.py  'def _fix_for_params()'
}}}
gets params as 
{{{
tuple('value1', 'badValue1', 'badValue2')
}}}
and then makes them into a set 
{{{
enumerate(set(params))
}}}
. This changes the order of params, and assigns them key (i.e arg0, arg1, ..). This also changes the SQL query and replaces '%s' with param key's (':arg0', ..). The order or param keys in SQL might not be in order anymore.

After SQL is executed this statement is logged. But for logging in 
{{{
django/db/backends/oracle/operations.py  'def last_executed_query()'
}}}
The code is replacing param keys in SQL (':arg0', ..) with params, but they do not match anymore, since they are not in order in SQL statement anymore

REproducable all the time with more than 1 param for SQL

"	Bug	closed	Database layer (models, ORM)	3.0	Release blocker	fixed	oracle sql log debug logging	Marti Raudsepp	Accepted	1	0	0	0	0	0
