#24254: Passing a query to "pk__in" of another query may result in invalid SQL
----------------------------------------------+--------------------
     Reporter:  bronger                       |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.7
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 Consider the following models:

 {{{
 from django.db import models


 class Father(models.Model):
     name = models.CharField(max_length=200)


 class Son(Father):

     class Meta:
         ordering = ("name",)
 }}}

 Then, the following query:

 {{{
 Son.objects.filter(pk__in=Son.objects.all().distinct()[:10])
 }}}

 results in an invalid SQL query.  SQLite complains with "only a single
 result allowed for a SELECT that is part of an expression".

--
Ticket URL: <https://code.djangoproject.com/ticket/24254>
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/050.c71660a649e7dff8d8fc340890b73693%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to