Changes between Initial Version and Version 1 of Ticket #32491, comment 2
- Timestamp:
- Feb 28, 2021, 5:58:57 PM (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #32491, comment 2
initial v1 13 13 It 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. 14 14 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"`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 do things like `jsonfield__name__gt="Simon"`