Opened 3 weeks ago

Last modified 3 weeks ago

#37373 assigned Cleanup/optimization

Deprecate QuerySet.extra(select, where, order_by)

Reported by: Simon Charette Owned by: Simon Charette
Component: Database layer (models, ORM) Version: 6.1
Severity: Normal Keywords: extra
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Simon Charette)

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.

In the weeks that followed the feature landing in main the future of extra() ​was discussed on the mailing list and reached a consensus that ​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.

Over the past decade all the tickets tagged accordingly have been triaged as achievable using the Expression API, early limitations such as ​not being able to filter by `RawSQL` expressions have ​been addressed #25367, and implicit behaviour such as the way extra(select) affects the order of SELECT members ​have had proper alternatives implemented #28900.

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 ​a torn in the way of refactors and ​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).

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.

Change History (4)

comment:1 by Simon Charette, 3 weeks ago

Has patch: set

comment:2 by Lily, 3 weeks ago

Triage Stage: Unreviewed → Accepted

comment:3 by Lily, 3 weeks ago

Triage Stage: Accepted → Ready for checkin

comment:4 by Simon Charette, 3 weeks ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top