#25021: HStore values query with contains does not actually work -------------------------------------+------------------------------------- Reporter: amagidow | Owner: nobody Type: Bug | Status: new Component: Database layer | Version: 1.8 (models, ORM) | Keywords: HStore, Postgresql, Severity: Normal | queries Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- When using an HStore {{{__values}}} query with {{{__contains}}} chained on to it, the query does not work as expected in Django 1.8.2. Expected action is that any values which contain the text will be returned from the query.
From my own app (I've removed some of the queryset results to make this easier to read) {{{ >>> query1 [<LanguageDatum: \xf0i, This (m), And, >, <LanguageDatum: hadi, This (f), AfgA, >, <LanguageDatum: -e, His, ArBah, >, '...(remaining elements truncated)...'] >>> query1.filter(multigloss__values__contains=["This"]) [] >>> query1.filter(multigloss__values__contains=["This (f)"]) [<LanguageDatum: hadi, This (f), AfgA, >, <LanguageDatum: \xf0i, This (f), ArAnz, >, '...(remaining elements truncated)...'] >>> query1.filter(multigloss__values__contains=["His"]) [<LanguageDatum: -e, His, ArBah, >, <LanguageDatum: -eh, His, ArBah, >, <LanguageDatum: -hu, His, Chd, >, <LanguageDatum: -u, His, Chd, > '...(remaining elements truncated)...'] >>> query1.filter(multigloss__values__contains=["Hi"]) [] }}} The expected result would be that the queries would return any data whose 'multigloss' values contain the string, not only those strings which are exactly identical. The example in the documentation should also fail if you did not include the entire word "collie" (I have not tested, this is a hypothesized result): {{{ >>> Dog.objects.create(name='Rufus', data={'breed': 'labrador'}) >>> Dog.objects.create(name='Meg', data={'breed': 'collie', 'owner': 'Bob'}) >>> Dog.objects.filter(data__values__contains=['collie']) [<Dog: Meg>] >>>#Hypothesized example! >>> Dog.objects.filter(data__values__contains=['coll']) [] >>>#Should have returned [Dog: Meg] }}} If this is not how {{{__values__contains}}} is supposed to work, this should be clarified in the documentation since it is extremely unclear how to do a search for values within the HStore that match a certain criterion (such as containing a string). -- Ticket URL: <https://code.djangoproject.com/ticket/25021> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/051.886ffd86ffe32f982e51ac971482de1b%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.