MCPcopy
hub / github.com/django/django / set_limits

Method set_limits

django/db/models/sql/query.py:2189–2210  ·  view source on GitHub ↗

Adjust the limits on the rows retrieved. Use low/high to set these, as it makes it more Pythonic to read and write. When the SQL query is created, convert them to the appropriate offset and limit values. Apply any limits passed in here to the existing constraints. A

(self, low=None, high=None)

Source from the content-addressed store, hash-verified

2187 return any(isinstance(c, NothingNode) for c in self.where.children)
2188
2189 def set_limits(self, low=None, high=None):
2190 """
2191 Adjust the limits on the rows retrieved. Use low/high to set these,
2192 as it makes it more Pythonic to read and write. When the SQL query is
2193 created, convert them to the appropriate offset and limit values.
2194
2195 Apply any limits passed in here to the existing constraints. Add low
2196 to the current low value and clamp both to any existing high value.
2197 """
2198 if high is not None:
2199 if self.high_mark is not None:
2200 self.high_mark = min(self.high_mark, self.low_mark + high)
2201 else:
2202 self.high_mark = self.low_mark + high
2203 if low is not None:
2204 if self.high_mark is not None:
2205 self.low_mark = min(self.high_mark, self.low_mark + low)
2206 else:
2207 self.low_mark = self.low_mark + low
2208
2209 if self.low_mark == self.high_mark:
2210 self.set_empty()
2211
2212 def clear_limits(self):
2213 """Clear any existing limits."""

Callers 4

__getitem__Method · 0.80
getMethod · 0.80
_earliestMethod · 0.80
existsMethod · 0.80

Calls 1

set_emptyMethod · 0.95

Tested by

no test coverage detected