Get an OP_QUERY message.
(
options: int,
collection_name: str,
num_to_skip: int,
num_to_return: int,
query: Mapping[str, Any],
field_selector: Optional[Mapping[str, Any]],
opts: CodecOptions[Any],
)
| 424 | |
| 425 | |
| 426 | def _query_impl( |
| 427 | options: int, |
| 428 | collection_name: str, |
| 429 | num_to_skip: int, |
| 430 | num_to_return: int, |
| 431 | query: Mapping[str, Any], |
| 432 | field_selector: Optional[Mapping[str, Any]], |
| 433 | opts: CodecOptions[Any], |
| 434 | ) -> tuple[bytes, int]: |
| 435 | """Get an OP_QUERY message.""" |
| 436 | encoded = _dict_to_bson(query, False, opts) |
| 437 | if field_selector: |
| 438 | efs = _dict_to_bson(field_selector, False, opts) |
| 439 | else: |
| 440 | efs = b"" |
| 441 | max_bson_size = max(len(encoded), len(efs)) |
| 442 | return ( |
| 443 | b"".join( |
| 444 | [ |
| 445 | _pack_int(options), |
| 446 | bson._make_c_string(collection_name), |
| 447 | _pack_int(num_to_skip), |
| 448 | _pack_int(num_to_return), |
| 449 | encoded, |
| 450 | efs, |
| 451 | ] |
| 452 | ), |
| 453 | max_bson_size, |
| 454 | ) |
| 455 | |
| 456 | |
| 457 | def _query_compressed( |
no test coverage detected