Hi Ole and Matt, Sorry for getting back so late. I agree that having such a function would be very useful. I believe it can be done with most of the current implementation because I actually needed to compile the JSON path string from the KeyTransforms (except for PostgreSQL that uses a different syntax of its own). So, maybe I just need to add a check if it's an instance of JSONExtract and adapt accordingly.
However, I'm not really sure about killing the other lookups. I agree that it interferes with the possibility of using the lookup names as keys, but I was trying to retain all the functionalities from the original JSONField to make migration less painful. Mariusz is going to prepare a review for the current implementation, so I think we'll be able to have a discussion about this as well. Regards, Sage On Friday, 13 September 2019 11:09:14 UTC+7, schinckel wrote: > > Hi Ole, > > I'm interested in what you are trying to do with JSONExtract. I have a > subclass of Func called JSONBExtractPathText that I use with great success > to extract parts of a JSONB object. > > Also, as of Django 3.0, you can filter directly on an expression (that has > an output_field of BooleanField). > > Thus, you could write your first example as: > > MyModel.objects.filter(JSONBExtractPathText('field', Value('Foo the > bar?'), output_field=models.BooleanField()) > > I think you could possibly do the other stuff using either an > ExpressionWrapper, or at worst a Case(When()). > > (I hang out on #django on IRC if you want to discuss this in a more > interactive manner). > > Matt. > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/d3199e1e-97ed-4196-a94a-809e0eb063b0%40googlegroups.com.