Make Query.set_limits a setter
|Reported by:||jorgecarleitao||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Query.set_limits(low=None, high=None) is used to create LIMIT low OFFSET high - low.
However, as pointed out in this thread, it *adds* to the limits and doesn't *set* the limits.
Query is responsible for storing the SQL expression to be generated, I propose
Query.set_limits to be the interface to set the limits of the query, and make QuerySet responsible for adding the limits if required. I.e. I propose that
set_limits overrides the previous limits. In particular the following becomes equivalent:
Query.set_limits(a, b).set_limits(c, d) Query.set_limits(c, b)
Currently this method is used in:
QuerySet doesn't seem to be using the add part anyway: neither
_earliest_or_latest (i.e. the methods that use it) nor
__getitem__ return a new