INNER CODE UNIT · Python

_handle_boolean_operator

mongomock/mongomock · mongomock/aggregate.py:337

    def _handle_boolean_operator(self, operator, values):
        if operator == '$and':
            return all(self._parse_to_bool(value) for value in values)
        if operator == '$or':
            return any(self._parse_to_bool(value) for value in values)
        if operator == '$not':
            return not self._parse_to_bool(values)
        # This should never happen: it is only a safe fallback if something went wrong.
        raise NotImplementedError(  # pragma: no cover
            f"Although '{operator}' is a valid boolean operator for the "
            f'aggregation pipeline, it is currently not implemented'
            f' in Mongomock.'
        )

    def _handle_arithmetic_operator(self, operator, values):
        if operator in unary_arithmetic_operators:
            try:
                number = self.parse(values)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…