#36644: Enable using an empty order_by() to disable implicit primary key
ordering
in first()
-------------------------------------+-------------------------------------
Reporter: Lily | Type: New
| feature
Status: new | Component: Database
| layer (models, ORM)
Version: dev | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
As discussed in https://github.com/django/new-features/issues/71, update
the interaction between `order_by` and `first` to enable this behaviour:
{{{
# Existing
MyModel.objects.first() # first, ordered by `pk`
MyModel.objects.order_by("pk").first() # as above
MyModel.objects.order_by("name").first() # first, ordered by `name`
# New
MyModel.objects.order_by().first() # first, but in whatever order the
database returns it
}}}
This will interact with
[https://docs.djangoproject.com/en/5.2/ref/models/options/#django.db.models.Options.ordering
default orderings (`Meta.ordering`)], which will need some careful
handling.
--
Ticket URL: <https://code.djangoproject.com/ticket/36644>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/01070199be52432d-1ba15520-e7ec-4651-a62b-20c055795943-000000%40eu-central-1.amazonses.com.