Commit b3316278 by Roman Krejcik

avoid executing empty batch, it has no effect

parent 84ddd38e
...@@ -125,9 +125,11 @@ class ParseBatcher(ParseBase): ...@@ -125,9 +125,11 @@ class ParseBatcher(ParseBase):
Given a list of create, update or delete methods to call, call all Given a list of create, update or delete methods to call, call all
of them in a single batch operation. of them in a single batch operation.
""" """
#accepts also empty list (or generator) - it allows call batch directly methods = list(methods) # methods can be iterator
# with query result (eventually empty) if not methods:
queries, callbacks = list(zip(*[m(batch=True) for m in methods])) or ([], []) #accepts also empty list (or generator) - it allows call batch directly with query result (eventually empty)
return
queries, callbacks = list(zip(*[m(batch=True) for m in methods]))
# perform all the operations in one batch # perform all the operations in one batch
responses = self.execute("", "POST", requests=queries) responses = self.execute("", "POST", requests=queries)
# perform the callbacks with the response data (updating the existing # perform the callbacks with the response data (updating the existing
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment