{{{
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
--
Ticket URL: <https://code.djangoproject.com/ticket/31271>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* component: Uncategorized => Database layer (models, ORM)
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
Comment:
Thanks for this report. `last_execute_query()` didn't interpolate
parameters before 79065b55a70cd220820a260a1c54851b7be0615a, so we can
treat this as a regression. It seems that the only reasonable solution is
to use mechanism that preserves ordering in `_fix_for_params()`, but it
can be tricky to add a regression test. I was not able to reproduce an
incorrect behavior but I agree that this can happen.
Would you like to prepare a patch?
--
Ticket URL: <https://code.djangoproject.com/ticket/31271#comment:1>
Comment (by Hans Aarne Liblik):
Sadly, I don't have the knowhow.
--
Ticket URL: <https://code.djangoproject.com/ticket/31271#comment:2>
* cc: Marti Raudsepp (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/31271#comment:3>
* owner: nobody => felixxm
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/31271#comment:4>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/12465 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/31271#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"2a038521c4eabdc5f6d5026d3dd6d22868e329cd" 2a038521]:
{{{
#!CommitTicketReference repository=""
revision="2a038521c4eabdc5f6d5026d3dd6d22868e329cd"
Fixed #31271 -- Preserved ordering when unifying query parameters on
Oracle.
This caused misplacing parameters in logged SQL queries.
Regression in 79065b55a70cd220820a260a1c54851b7be0615a.
Thanks Hans Aarne Liblik for the report.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31271#comment:6>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"2448b3182c75cce5d22dd80be0fb5cba6104c364" 2448b31]:
{{{
#!CommitTicketReference repository=""
revision="2448b3182c75cce5d22dd80be0fb5cba6104c364"
[3.0.x] Fixed #31271 -- Preserved ordering when unifying query parameters
on Oracle.
This caused misplacing parameters in logged SQL queries.
Regression in 79065b55a70cd220820a260a1c54851b7be0615a.
Thanks Hans Aarne Liblik for the report.
Backport of 2a038521c4eabdc5f6d5026d3dd6d22868e329cd from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31271#comment:7>