(field, op, value)
| 505 | |
| 506 | |
| 507 | def _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] |
no test coverage detected