﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
22885	Make Query.set_limits a setter	jorgecarleitao	nobody	"`Query.set_limits(low=None, high=None)` is used to create LIMIT low OFFSET high - low.

However, as pointed out in [https://groups.google.com/d/msg/django-developers/oqgtvFE5y84/gZK6ccOmjRcJ this thread], it *adds* to the limits and doesn't *set* the limits.

Since `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.__getitem__`, 
* `QuerySet._earliest_or_latest` (calls `clone.query.set_limits(high=1)`)
* `Query.has_results` (calls `clone.set_limits(high=1)`)

and `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 `QuerySet`.
"	Cleanup/optimization	closed	Database layer (models, ORM)	dev	Normal	wontfix		jorgecarleitao	Unreviewed	0	0	0	0	0	0
