You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
self = <mongomock.aggregate._Parser object at 0x1357fe1c0>
operator = '$arrayElemAt', values = ['$themes', '$idx']
def _handle_project_operator(self, operator, values):
if operator in _GROUPING_OPERATOR_MAP:
return _GROUPING_OPERATOR_MAP[operator](self.parse_many(values))
if operator == '$arrayElemAt':
key, index = values
array = self._parse_basic_expression(key)
return array[index]
TypeError: list indices must be integers or slices, not str
Simple if statement that checks if index is an integer and if not parsing expression fixed the issue:
def _handle_project_operator(self, operator, values):
if operator in _GROUPING_OPERATOR_MAP:
return _GROUPING_OPERATOR_MAP[operator](self.parse_many(values))
if operator == '$arrayElemAt':
key, index = values
array = self._parse_basic_expression(key)
if not isinstance(index, int):
index = self._parse_basic_expression(index)
return array[index]
raise NotImplementedError("Although '%s' is a valid project operator for the "
'aggregation pipeline, it is currently not implemented '
'in Mongomock.' % operator)
The text was updated successfully, but these errors were encountered:
With query:
I get the following error:
Simple if statement that checks if index is an integer and if not parsing expression fixed the issue:
The text was updated successfully, but these errors were encountered: