[Django] #31271: Logged ORM query differs from executed one

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #31271: Logged ORM query differs from executed one

Django
#31271: Logged ORM query differs from executed one
-------------------------------------+-------------------------------------
               Reporter:             |          Owner:  nobody
  HansAarneLiblik                    |
                   Type:  Bug        |         Status:  new
              Component:             |        Version:  3.0
  Uncategorized                      |       Keywords:  oracle sql log
               Severity:  Normal     |  debug logging
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 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

--
Ticket URL: <https://code.djangoproject.com/ticket/31271>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/058.c4ad2867994df3ca0e41662c3d30f151%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #31271: Logged queries may interpolate parameters in the wrong order on Oracle. (was: Logged ORM query differs from executed one)

Django
#31271: Logged queries may interpolate parameters in the wrong order on Oracle.
-------------------------------------+-------------------------------------
     Reporter:  Hans Aarne Liblik    |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  3.0
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:  oracle sql log       |             Triage Stage:  Accepted
  debug logging                      |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by felixxm):

 * 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>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/073.87da64dbc2d4d40e8ddaaf3446a6c404%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #31271: Logged queries may interpolate parameters in the wrong order on Oracle.

Django
In reply to this post by Django
#31271: Logged queries may interpolate parameters in the wrong order on Oracle.
-------------------------------------+-------------------------------------
     Reporter:  Hans Aarne Liblik    |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  3.0
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:  oracle sql log       |             Triage Stage:  Accepted
  debug logging                      |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Hans Aarne Liblik):

 Sadly, I don't have the knowhow.

--
Ticket URL: <https://code.djangoproject.com/ticket/31271#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/073.6cee0c160d1d6e2d07227cdc847bbd8f%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #31271: Logged queries may interpolate parameters in the wrong order on Oracle.

Django
In reply to this post by Django
#31271: Logged queries may interpolate parameters in the wrong order on Oracle.
-------------------------------------+-------------------------------------
     Reporter:  Hans Aarne Liblik    |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  3.0
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:  oracle sql log       |             Triage Stage:  Accepted
  debug logging                      |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Marti Raudsepp):

 * cc: Marti Raudsepp (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/31271#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/073.32d13b2427e8d8a696654e362d827628%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #31271: Logged queries may interpolate parameters in the wrong order on Oracle.

Django
In reply to this post by Django
#31271: Logged queries may interpolate parameters in the wrong order on Oracle.
-------------------------------------+-------------------------------------
     Reporter:  Hans Aarne Liblik    |                    Owner:  felixxm
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  3.0
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:  oracle sql log       |             Triage Stage:  Accepted
  debug logging                      |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by felixxm):

 * owner:  nobody => felixxm
 * status:  new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/31271#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/073.ca5f4fac5b73efad78411b52c885abeb%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #31271: Logged queries may interpolate parameters in the wrong order on Oracle.

Django
In reply to this post by Django
#31271: Logged queries may interpolate parameters in the wrong order on Oracle.
-------------------------------------+-------------------------------------
     Reporter:  Hans Aarne Liblik    |                    Owner:  felixxm
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  3.0
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:  oracle sql log       |             Triage Stage:  Accepted
  debug logging                      |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by felixxm):

 * has_patch:  0 => 1


Comment:

 [https://github.com/django/django/pull/12465 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/31271#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/073.05893ef333076e7c57ce501100b5ff08%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #31271: Logged queries may interpolate parameters in the wrong order on Oracle.

Django
In reply to this post by Django
#31271: Logged queries may interpolate parameters in the wrong order on Oracle.
-------------------------------------+-------------------------------------
     Reporter:  Hans Aarne Liblik    |                    Owner:  felixxm
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  3.0
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:  fixed
     Keywords:  oracle sql log       |             Triage Stage:  Accepted
  debug logging                      |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

 * 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>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/073.0c14b9bb9510a0f949d9e52d5aa18117%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #31271: Logged queries may interpolate parameters in the wrong order on Oracle.

Django
In reply to this post by Django
#31271: Logged queries may interpolate parameters in the wrong order on Oracle.
-------------------------------------+-------------------------------------
     Reporter:  Hans Aarne Liblik    |                    Owner:  felixxm
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  3.0
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:  fixed
     Keywords:  oracle sql log       |             Triage Stage:  Accepted
  debug logging                      |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

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>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/073.deb62bc1a85411e61c9d501b227f2a19%40djangoproject.com.