Skip to content

Commit 5c5fefa

Browse files
authored
Merge pull request Azure#96 from lnlwd/fix-aggregate
Fixed dict_keys error on aggregated queries dict
2 parents e3d89e6 + da11973 commit 5c5fefa

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

pydocumentdb/execution_context/endpoint_component.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -30,37 +30,37 @@
3030
class _QueryExecutionEndpointComponent(object):
3131
def __init__(self, execution_context):
3232
self._execution_context = execution_context
33-
33+
3434
def __iter__(self):
3535
return self
36-
36+
3737
def next(self):
3838
return next(self._execution_context)
3939

4040
def __next__(self):
4141
# supports python 3 iterator
42-
return self.next()
42+
return self.next()
4343

4444
class _QueryExecutionOrderByEndpointComponent(_QueryExecutionEndpointComponent):
4545
"""Represents an endpoint in handling an order by query.
46-
46+
4747
For each processed orderby result it returns 'payload' item of the result
4848
"""
4949
def __init__(self, execution_context):
5050
super(self.__class__, self).__init__(execution_context)
51-
51+
5252
def next(self):
5353
return next(self._execution_context)['payload']
54-
54+
5555
class _QueryExecutionTopEndpointComponent(_QueryExecutionEndpointComponent):
5656
"""Represents an endpoint in handling top query.
57-
57+
5858
It only returns as many results as top arg specified.
5959
"""
6060
def __init__(self, execution_context, top_count):
6161
super(self.__class__, self).__init__(execution_context)
6262
self._top_count = top_count
63-
63+
6464
def next(self):
6565
if (self._top_count > 0):
6666
res = next(self._execution_context)
@@ -95,7 +95,7 @@ def next(self):
9595
for item in res:
9696
for operator in self._local_aggregators:
9797
if isinstance(item, dict) and len(item.keys()) > 0:
98-
operator.aggregate(item[item.keys()[0]])
98+
operator.aggregate(item[next(iter(item.keys()))])
9999
elif isinstance(item, numbers.Number):
100100
operator.aggregate(item)
101101
if self._results is None:
@@ -107,4 +107,4 @@ def next(self):
107107
self._result_index += 1
108108
return res
109109
else:
110-
raise StopIteration
110+
raise StopIteration

0 commit comments

Comments
 (0)