#26983: models.Manager query "filter(field__isnull=False)" not working in 1.10
----------------------------------------------+----------------------
     Reporter:  weidwonder                    |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.10
     Severity:  Normal                        |   Keywords:  queryset
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+----------------------
 models Manager:


 {{{
 class ModelManager(models.Manager):
     def get_queryset(self):
         return super(ModelManager,
 self).get_queryset().filter(parent__isnull=False)
 }}}

 models:


 {{{
 class Category(models.Model):
     parent = models.ForeignKey('Category', to_field='slug',
 db_column='parent',
                                max_length=32, blank=True, null=True,
                                related_name='models')
     name = models.CharField(max_length=50, blank=True, null=True)
     ....
     vehicle_models = ModelManager()

     class Meta:
         db_table = 'open_category'
         ordering = ['pinyin']

 }}}

 query:

 {{{
 Category.vehicle_models.filter(slug=model_slug).values('name').query
 }}}

 query's sql output is:


 {{{
 SELECT `open_category`.`name` FROM `open_category` WHERE
 (`open_category`.`parent` IS NULL AND `open_category`.`slug` = "suteng")
 ORDER BY `open_category`.`pinyin` ASC
 }}}

 it should be '''`open_category`.`parent` IS NOT NULL'''

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

Reply via email to