Changes between Initial Version and Version 4 of Ticket #37373
- Timestamp:
- Sep 30, 2026, 6:36:32 AM (3 weeks ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #37373
- Property Has patch set
- Property Triage Stage Unreviewed → Ready for checkin
-
Ticket #37373 – Description
initial v4 1 1 When the Expressions API was introduced to the ORM more than decade ago it paved the way for the safer injection of developer controlled SQL. 2 2 3 In the weeks that followed the feature landing in `main` the future of `extra()` [https://groups.google.com/g/django-developers/c/FojuU0syO8Y was discussed on the mailing list] and reached a consensus that [https://github.com/django/django/commit/e8cd65f8297928d3fa7ad3d338953a4423028713 the documentation should discourage its usage] #25213, direct users to file a ticket with the `extra` keyword if they encounter a use case they believe would still require its usage, and statethat we would no longer be improving or fixing bugs for it.3 In the weeks that followed the feature landing in `main` the future of `extra()` [https://groups.google.com/g/django-developers/c/FojuU0syO8Y was discussed on the mailing list] and reached a consensus that [https://github.com/django/django/commit/e8cd65f8297928d3fa7ad3d338953a4423028713 the documentation should discourage its usage] #25213, users should be directed to file a ticket with the `extra` keyword if they encounter a use case they believe would still require its usage, and stated that we would no longer be improving or fixing bugs for it. 4 4 5 5 Over the past decade all the tickets [https://code.djangoproject.com/query?component=Database+layer+(models%2C+ORM)&description=~extra&keywords=~extra&status=closed&order=id&desc=1&col=id&col=summary&col=component&col=owner&col=type tagged accordingly] have been triaged as achievable using the Expression API, early limitations such as [https://groups.google.com/g/django-developers/c/FojuU0syO8Y/m/5NOKchNyDgAJ not being able to filter by `RawSQL` expressions] have [https://github.com/django/django/commit/4137fc2efce2dde48340728b8006fc6d66b9e3a5 been addressed] #25367, and implicit behaviour such as the way `extra(select)` affects the order of `SELECT` members [https://github.com/django/django/commit/65ad4ade74dc9208b9d686a451cd6045df0c9c3a have had] proper alternatives implemented #28900. 6 6 7 As the obsolescence of `extra(select, where, order_by)` was confirmed over the years new features were added without taking it into consideration and it slowly slipped into abandon as it became [https://github.com/django/django/commit/65ad4ade74dc9208b9d686a451cd6045df0c9c3a a torn in the way of refactors] and [https://github.com/django/django/commit/65ad4ade74dc9208b9d686a451cd6045df0c9c3a functionally defunct] I think the time has come to consider fully deprecating it except for the `tables` option which cannot be emulated with the Expressions API yet #5929.7 As the obsolescence of `extra(select, where, order_by)` was confirmed over the years new features were added without taking it into consideration and it slowly slipped into abandon as it became [https://github.com/django/django/commit/65ad4ade74dc9208b9d686a451cd6045df0c9c3a a torn in the way of refactors] and [https://github.com/django/django/commit/65ad4ade74dc9208b9d686a451cd6045df0c9c3a functionally defunct]. I'm filing this ticket because I think the time has come to consider deprecating it except for the `tables` option which cannot be emulated with the Expressions API yet (see #5929). 8 8 9 9 Since `extra(select, where, order_by)` has been around for almost as long as the project itself I suggest keeping shims meant to also be removed over the few internal `extra` methods and attributes of `sql.Query` during the deprecation period to allow third-party applications to gracefully stop relying on them.