#33785: Broken __in lookup for keys of json field
-------------------------------------+-------------------------------------
Reporter: Maksim | Owner: nobody
Iakovlev |
Type: Bug | Status: new
Component: Database | Version: 3.2
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
For example I have a model with json field:
{{{
class MyModel():
model_field = JsonField()
}}}
I create 3 records in db:
{{{
x1 = MyModel(model_field={json_field=''}).save()
x2 = MyModel(model_field={json_field=None}).save()
x3 = MyModel(model_field={json_field='foobar'}).save()
}}}
And then I want for filter all records which contains non-empty json_field
like this:
{{{
MyModel.objects.exclude(model_field__json_field__in=['', None])
}}}
I expect only x3 record in result, but x2 presents too. This is also
wrong:
{{{
MyModel.objects.exclude(model_field__json_field='').exclude(model_field__json_field__isnull=True)
}}}
Only this filter works as expected:
{{{
MyModel.objects.exclude(model_field__json_field='').exclude(model_field__json_field=None)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33785>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701816250c90e-174ea809-5ed7-48b8-81ea-26850f1f4b24-000000%40eu-central-1.amazonses.com.