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

Function _prepare_query_for_iterable

mongoengine/queryset/transform.py:507–527  ·  view source on GitHub ↗
(field, op, value)

Source from the content-addressed store, hash-verified

505
506
507def _prepare_query_for_iterable(field, op, value):
508 # We need a special check for BaseDocument, because - although it's iterable - using
509 # it as such in the context of this method is most definitely a mistake.
510 BaseDocument = _import_class("BaseDocument")
511
512 if isinstance(value, BaseDocument):
513 raise TypeError(
514 "When using the `in`, `nin`, `all`, or "
515 "`near`-operators you can't use a "
516 "`Document`, you must wrap your object "
517 "in a list (object -> [object])."
518 )
519
520 if not hasattr(value, "__iter__"):
521 raise TypeError(
522 "The `in`, `nin`, `all`, or "
523 "`near`-operators must be applied to an "
524 "iterable (e.g. a list)."
525 )
526
527 return [field.prepare_query_value(op, v) for v in value]

Callers 2

queryFunction · 0.85
updateFunction · 0.85

Calls 2

_import_classFunction · 0.90
prepare_query_valueMethod · 0.45

Tested by

no test coverage detected