Internal update / replace helper.
(
self,
conn: AsyncConnection,
criteria: Mapping[str, Any],
document: Union[Mapping[str, Any], _Pipeline],
upsert: bool = False,
multi: bool = False,
write_concern: Optional[WriteConcern] = None,
op_id: Optional[int] = None,
ordered: bool = True,
bypass_doc_val: Optional[bool] = None,
collation: Optional[_CollationIn] = None,
array_filters: Optional[Sequence[Mapping[str, Any]]] = None,
hint: Optional[_IndexKeyHint] = None,
session: Optional[AsyncClientSession] = None,
retryable_write: bool = False,
let: Optional[Mapping[str, Any]] = None,
sort: Optional[Mapping[str, Any]] = None,
comment: Optional[Any] = None,
)
| 976 | return InsertManyResult(inserted_ids, write_concern.acknowledged) |
| 977 | |
| 978 | async def _update( |
| 979 | self, |
| 980 | conn: AsyncConnection, |
| 981 | criteria: Mapping[str, Any], |
| 982 | document: Union[Mapping[str, Any], _Pipeline], |
| 983 | upsert: bool = False, |
| 984 | multi: bool = False, |
| 985 | write_concern: Optional[WriteConcern] = None, |
| 986 | op_id: Optional[int] = None, |
| 987 | ordered: bool = True, |
| 988 | bypass_doc_val: Optional[bool] = None, |
| 989 | collation: Optional[_CollationIn] = None, |
| 990 | array_filters: Optional[Sequence[Mapping[str, Any]]] = None, |
| 991 | hint: Optional[_IndexKeyHint] = None, |
| 992 | session: Optional[AsyncClientSession] = None, |
| 993 | retryable_write: bool = False, |
| 994 | let: Optional[Mapping[str, Any]] = None, |
| 995 | sort: Optional[Mapping[str, Any]] = None, |
| 996 | comment: Optional[Any] = None, |
| 997 | ) -> Optional[Mapping[str, Any]]: |
| 998 | """Internal update / replace helper.""" |
| 999 | validate_boolean("upsert", upsert) |
| 1000 | collation = validate_collation_or_none(collation) |
| 1001 | write_concern = write_concern or self.write_concern |
| 1002 | acknowledged = write_concern.acknowledged |
| 1003 | update_doc: dict[str, Any] = { |
| 1004 | "q": criteria, |
| 1005 | "u": document, |
| 1006 | "multi": multi, |
| 1007 | "upsert": upsert, |
| 1008 | } |
| 1009 | if collation is not None: |
| 1010 | if not acknowledged: |
| 1011 | raise ConfigurationError("Collation is unsupported for unacknowledged writes.") |
| 1012 | else: |
| 1013 | update_doc["collation"] = collation |
| 1014 | if array_filters is not None: |
| 1015 | if not acknowledged: |
| 1016 | raise ConfigurationError("arrayFilters is unsupported for unacknowledged writes.") |
| 1017 | else: |
| 1018 | update_doc["arrayFilters"] = array_filters |
| 1019 | if hint is not None: |
| 1020 | if not acknowledged and conn.max_wire_version < 8: |
| 1021 | raise ConfigurationError( |
| 1022 | "Must be connected to MongoDB 4.2+ to use hint on unacknowledged update commands." |
| 1023 | ) |
| 1024 | if not isinstance(hint, str): |
| 1025 | hint = helpers_shared._index_document(hint) |
| 1026 | update_doc["hint"] = hint |
| 1027 | if sort is not None: |
| 1028 | if not acknowledged and conn.max_wire_version < 25: |
| 1029 | raise ConfigurationError( |
| 1030 | "Must be connected to MongoDB 8.0+ to use sort on unacknowledged update commands." |
| 1031 | ) |
| 1032 | common.validate_is_mapping("sort", sort) |
| 1033 | update_doc["sort"] = sort |
| 1034 | |
| 1035 | command = {"update": self.name, "ordered": ordered, "updates": [update_doc]} |
nothing calls this directly
no test coverage detected