#25107: Inconsistent results when combining Q objects filtering on m2m fields
-------------------------------------+-------------------------------------
     Reporter:  AlexHill             |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  1.8
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by AlexHill):

 Hey Anssi,

 That does make sense. I think this warrants a mention in the docs at least
 though.

 I think it also hints at an inconsistency in the ORM somewhere, because
 the subselect is redundant – shouldn't the generated SQL just look like
 this if everything is targeting the same tag?

 {{{#!python
     SELECT DISTINCT number.id
       FROM number
 INNER JOIN number_tags ON number.id = number_tags.number_id
 INNER JOIN category ON number_tags.category_id = category.id
      WHERE category.tag = 'odd' AND NOT category.tag ='prime'
 }}}

 Thanks,
 Alex

--
Ticket URL: <https://code.djangoproject.com/ticket/25107#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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.912948b294b01e9986a2c00d7581bbe0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to