[Django] #34868: Add K as an alias for KeyTransform.from_lookup

16 views
Skip to first unread message

Django

unread,
Sep 22, 2023, 4:37:33 PM9/22/23
to django-...@googlegroups.com
#34868: Add K as an alias for KeyTransform.from_lookup
-------------------------------------+-------------------------------------
Reporter: Paolo | Owner: nobody
Melchiorre |
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: dev
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I propose to add K as an alias for KeyTransform.from_lookup

It's something possible to do in `django.contrib.postgres` before Django
3.1 and it can still be useful now to get non-textual data back from
database.

This would be an example of use and I show the difference with KT

{{{#!pycon
>>> qs = MyModel.objects.all()
>>> values = qs.values_list(
K("value__true"),
K("value__false"),
K("value__none"),
K("value__dict"),
K("value__list"),
)
[True, False, None, {"k": "v"}, [None, True, False]]
>>> text_values = qs.values_list(
KT("value__true"),
KT("value__false"),
KT("value__none"),
KT("value__dict"),
KT("value__list"),
)
["true", "false", "null", '{"k":"v"}', "[null,true,false]"]
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34868>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 22, 2023, 4:42:46 PM9/22/23
to django-...@googlegroups.com
#34868: Add K as an alias for KeyTransform.from_lookup
-------------------------------------+-------------------------------------
Reporter: Paolo Melchiorre | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: json key type | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 1

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Paolo Melchiorre):

* keywords: => json key type
* needs_docs: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34868#comment:1>

Django

unread,
Sep 23, 2023, 3:05:38 AM9/23/23
to django-...@googlegroups.com
#34868: Add K as an alias for KeyTransform.from_lookup
-------------------------------------+-------------------------------------
Reporter: Paolo Melchiorre | Owner: nobody
Type: | Status: closed

Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: wontfix

Keywords: json key type | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => wontfix


Comment:

As far as I'm aware exposing a new API is unnecessary, `F()` should work
just fine.

--
Ticket URL: <https://code.djangoproject.com/ticket/34868#comment:2>

Reply all
Reply to author
Forward
0 new messages