Execute operations.
(
self,
session: Optional[ClientSession],
operation: str,
)
| 734 | return self.execute_command_unack(conn) |
| 735 | |
| 736 | def execute( |
| 737 | self, |
| 738 | session: Optional[ClientSession], |
| 739 | operation: str, |
| 740 | ) -> Any: |
| 741 | """Execute operations.""" |
| 742 | if not self.ops: |
| 743 | raise InvalidOperation("No operations to execute") |
| 744 | if self.executed: |
| 745 | raise InvalidOperation("Bulk operations can only be executed once.") |
| 746 | self.executed = True |
| 747 | session = _validate_session_write_concern(session, self.write_concern) |
| 748 | |
| 749 | if not self.write_concern.acknowledged: |
| 750 | with self.client._conn_for_writes(session, operation) as connection: |
| 751 | if connection.max_wire_version < 25: |
| 752 | raise InvalidOperation( |
| 753 | "MongoClient.bulk_write requires MongoDB server version 8.0+." |
| 754 | ) |
| 755 | self.execute_no_results(connection) |
| 756 | return ClientBulkWriteResult(None, False, False) # type: ignore[arg-type] |
| 757 | |
| 758 | result = self.execute_command(session, operation) |
| 759 | return ClientBulkWriteResult( |
| 760 | result, |
| 761 | self.write_concern.acknowledged, |
| 762 | self.verbose_results, |
| 763 | ) |
nothing calls this directly
no test coverage detected