#27205: Django Postgres ArrayField __contain lookup does not behave expectedly
----------------------------------------------+----------------------------
     Reporter:  Dean-Christian-Armada         |      Owner:  nobody
         Type:  Uncategorized                 |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.10
     Severity:  Normal                        |   Keywords:  postgresql,
                                              |  arrayfield
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+----------------------------
 This is my models.py:


 {{{
 class Dog(models.Model):
     name = models.CharField(max_length=200)
     data = JSONField()

     def __unicode__(self):
         return self.name
 }}}

 I did this in the django shell:



 {{{
 Dog.objects.create(name='Rufus', data={ 'breed': 'labrador', 'owner': {
 'name': 'Bob', 'other_pets': [{  'name': 'Fishy',  }], }, })
 Dog.objects.create(name='Meg', data={'breed': 'collie'})
 Dog.objects.filter(data__breed__contains='l')

 }}}


 However when I did the last command it gave me an empy queryset return:


 {{{
 <QuerySet []>

 }}}


 The two objects (Meg and Rufus) should have both returned because they
 both contain l

 This is the query of the ORM:


 {{{
 SELECT "post_tagging_dog"."id", "post_tagging_dog"."name",
 "post_tagging_dog"."data" FROM "post_tagging_dog" WHERE
 "post_tagging_dog"."data" -> 'breed' @> '"l"'

 }}}

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

Reply via email to