Changes between Initial Version and Version 1 of Ticket #32491, comment 2


Ignore:
Timestamp:
Feb 28, 2021, 5:58:57 PM (4 years ago)
Author:
Simon Charette

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #32491, comment 2

    initial v1  
    1313It could be done by having transforms used `for_save` have access to `output_field` of the left hand side of the `UPDATE`/`INSERT` (e.g a `CharField`) in this case and decide whether `->>` or `->` should be used but that would be slightly backward incompatible.
    1414
    15 An alternative could be to introduce an `__astext` lookup on `JSONField` that would translate to the usage of `KeyTextTransform`. That would make it explicit which SQL operator must be used and a similar approach could be used for `__asint` and `__asfloat` to [https://github.com/django/django/blob/64a0d1ef6e7a6739148996e9584bbb61fe3dcc60/django/db/models/fields/json.py#L462-L533 remove the lookups hacks for textual and numeric values] as right now it's not possible to go things like `jsonfield__name__gt="Simon"`
     15An alternative could be to introduce an `__astext` lookup on `JSONField` that would translate to the usage of `KeyTextTransform`. That would make it explicit which SQL operator must be used and a similar approach could be used for `__asint` and `__asfloat` to [https://github.com/django/django/blob/64a0d1ef6e7a6739148996e9584bbb61fe3dcc60/django/db/models/fields/json.py#L462-L533 remove the lookups hacks for textual and numeric values] as right now it's not possible to do things like `jsonfield__name__gt="Simon"`
Back to Top