Skip to content
Snippets Groups Projects

ENH: new `page_length` parameter for execute_query

Merged Timm Fitschen requested to merge f-query-paging into dev
All threads resolved!
@@ -4391,7+4391,7 @@
Whether to use the server-side query cache (equivalent to adding a
"cache" flag) to the Query object. Defaults to True.
page_length : int
Whether to use paging. If page_length > 0 this method returns a
generator (to be used in a for-loop or with list-comprehension).
The generator yields containers with up to page_length entities.
Otherwise, paging is disabled, as well as for count queries and
@@ -4421,7+4421,7 @@
query_dict["query"] = str(self.q)
has_paging = False
is_count_query = self.q.lower().startswith('count')
is_count_query = self.q.split()[0].lower() == "count" if len(self.q.split()) > 0 else False
if not unique and not is_count_query and page_length is not None and page_length > 0:
has_paging = True
@@ -4434,9 +4434,7 @@ class Query():
self.cached = cresp.query.cached
self.etag = cresp.query.etag
if is_count_query and len(cresp) == 0:
# this was a count query
if is_count_query:
return self.results
if raise_exception_on_error:
@@ -4480,8 +4478,8 @@ def execute_query(q, unique=False, raise_exception_on_error=True, cache=True,
Whether an exception should be raised when there are errors in the
resulting entities. Defaults to True.
cache : bool
Whether to use the query cache (equivalent to adding a "cache" flag).
Defaults to True.
Whether to use the query server-side cache (equivalent to adding a
"cache" flag). Defaults to True.
flags : dict of str
Flags to be added to the request.
page_length : int
Loading