#27179: Bug: error when trying to filter using regex/iregex on a key in a django.contrib.postgres.fields.JSONField ----------------------------------+------------------------------------ Reporter: jrhouston | Owner: Type: Bug | Status: new Component: contrib.postgres | Version: 1.10 Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 1 | UI/UX: 0 ----------------------------------+------------------------------------
Comment (by charettes): @jrhouston, the following should do: {{{#!python from django.contrib.postgres.fields.jsonb import KeyTransform from django.db.functions import Cast instance = JSONModel.objects.create(field={'foo': 123}) foo = JSONModel.objects.annotate( foo=Cast(KeyTransform('foo', 'field'), models.IntegerField()) ).values_list('foo', flat=True).get(pk=instance.pk) self.assertEqual(foo, 123) }}} -- Ticket URL: <https://code.djangoproject.com/ticket/27179#comment:6> 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/067.757fa9fc23640aff7175fce33839765a%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.