#19493: annotate(Count()) does not work properly with django.db.backends.oracle
-------------------------------------+-------------------------------------
     Reporter:  kimvais@…            |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.4
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |             Triage Stage:  Accepted
     Keywords:  oracle               |      Needs documentation:  0
    Has patch:  0                    |  Patch needs improvement:  0
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------
Changes (by russellm):

 * type:  Uncategorized => Bug
 * stage:  Unreviewed => Accepted


Comment:

 I'm guessing an important, but unstated part of this bug report is that
 your model needs to have an implicit ordering on the primary key; I
 haven't been able to reproduce the "working" SQL without that important
 element.

 The "wrong" results are being generated because the PK is included in the
 GROUP BY clause; I'm guessing this is because the ORDER BY clause exists.
 PKs aren't required for all querysets -- values() querysts can drop them
 under most circumstances, but they will be added back under certain
 ordering or join situations. I'm guessing the Oracle backend's logic is
 slightly different, and isn't pruning the PK as needed.

 Regarding the call to raw() -- Yes, it needs to have a PK field present;
 however, the fact that you were able to get an infinite recursion is
 alarming. I haven't been able to reproduce on a non-Oracle backend; if
 this problem isn't fixed by the fix for the COUNT, then it should be
 opened as a separate ticket.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/19493#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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to