#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: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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, direct users to file a ticket with the extra keyword if they encounter a use case they believe would still require its usage, and state 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 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.

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 (0)

Note: See TracTickets for help on using tickets.
Back to Top