Hi Mani,

No response can mean either the readers here do not have the same problem 
and have no comment, or your implementation does not require much 
discussion. In any case, you could continue with the process by proposing a 
formal patch, and getting someone to review it once it meets the 
requirements for a finished patch.

See https://docs.djangoproject.com/en/dev/internals/contributing/ 
and https://docs.djangoproject.com/en/dev/intro/contributing/

The change should come with tests and documentation.

Regarding your implementation, I'm not thrilled with the requirement for 
users to provide a Cast. If casting needs to occur, it'd be preferable to 
have the interface of JSONF(lookup, output_field), and then wrap self with 
Cast(self, self.output_field).

Is there any particular reason why you chose a separate expression type 
rather than containing the functionality within the existing F expression? 
I'd be keen to hear the pros/cons of each.

On Sunday, 11 November 2018 13:51:57 UTC+11, Mani S wrote:
>
> Hi devs,
> Any update on this? Would like to know your thoughts
>
>
>
>
> Thanks,
> Mani
>
> On Sun, Oct 28, 2018 at 1:28 AM Mani S <manikan...@gmail.com <javascript:>> 
> wrote:
>
>> Django's F objects does not perform JSON lookups. A ticket has been 
>> raised for the same https://code.djangoproject.com/ticket/29769
>>
>> I have written a customer expression for querying JSONField and
>> * it works!*
>>
>> class KeyTextTransformFactory:
>>
>>     def __init__(self, key_name):
>>         self.key_name = key_name
>>
>>     def __call__(self, *args, **kwargs):
>>         return KeyTextTransform(self.key_name, *args, **kwargs)
>>
>> class JSONF(F):
>>
>>     def resolve_expression(self, query=None, allow_joins=True, reuse=None, 
>> summarize=False, for_save=False):
>>         rhs = super().resolve_expression(query, allow_joins, reuse, 
>> summarize, for_save)
>>
>>         field_list = self.name.split(LOOKUP_SEP)
>>         for name in field_list[1:]:
>>             rhs = KeyTextTransformFactory(name)(rhs)
>>         return rhs
>>
>> It is necessary to include Cast in rhs,
>> Sample.objects.filter(jsonfield__lookup__value=Cast(JSONF('value'), 
>> IntegerField())) 
>>
>>
>> Comment ref: https://code.djangoproject.com/ticket/29769#comment:5
>>
>>
>> Note: This is my first contribution in Django source code, any 
>> comments/suggestions would help me learn the process better.
>>
>>
>>
>>
>>
>> Thank you,
>> Mani
>>
>> -- 
>> 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-develop...@googlegroups.com <javascript:>.
>> To post to this group, send email to django-d...@googlegroups.com 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/django-developers.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-developers/88f52ca0-ebd9-4139-b88e-9f21292b7603%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-developers/88f52ca0-ebd9-4139-b88e-9f21292b7603%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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 post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/b45f2c10-2285-4585-b303-4fb12de209b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to