MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / prepare_query_value

Method prepare_query_value

mongoengine/fields.py:950–968  ·  view source on GitHub ↗
(self, op, value)

Source from the content-addressed store, hash-verified

948 super().validate(value)
949
950 def prepare_query_value(self, op, value):
951 # Validate that the `set` operator doesn't contain more items than `max_length`.
952 if op == "set" and self.max_length is not None and len(value) > self.max_length:
953 self.error("List is too long")
954
955 if self.field:
956 # If the value is iterable and it's not a string nor a
957 # BaseDocument, call prepare_query_value for each of its items.
958 is_iter = hasattr(value, "__iter__")
959 eligible_iter = is_iter and not isinstance(value, (str, BaseDocument))
960 if (
961 op in ("set", "unset", "gt", "gte", "lt", "lte", "ne", None)
962 and eligible_iter
963 ):
964 return [self.field.prepare_query_value(op, v) for v in value]
965
966 return self.field.prepare_query_value(op, value)
967
968 return super().prepare_query_value(op, value)
969
970
971class EmbeddedDocumentListField(ListField):

Callers

nothing calls this directly

Calls 2

errorMethod · 0.80
prepare_query_valueMethod · 0.45

Tested by

no test coverage detected