Skip to content

Commit dc674a0

Browse files
committed
Rename BulkWriteCommandBuilder to ClientBulkWrite
Also renames the operation class to ClientBulkWriteCommand to avoid aliasing in Client.
1 parent e6d5397 commit dc674a0

11 files changed

+26
-26
lines changed

Diff for: src/Client.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
use MongoDB\Model\BSONArray;
4242
use MongoDB\Model\BSONDocument;
4343
use MongoDB\Model\DatabaseInfo;
44-
use MongoDB\Operation\ClientBulkWrite;
44+
use MongoDB\Operation\ClientBulkWriteCommand;
4545
use MongoDB\Operation\DropDatabase;
4646
use MongoDB\Operation\ListDatabaseNames;
4747
use MongoDB\Operation\ListDatabases;
@@ -193,26 +193,26 @@ final public function addSubscriber(Subscriber $subscriber): void
193193
}
194194

195195
/**
196-
* Executes multiple write operations.
196+
* Executes multiple write operations across multiple namespaces.
197197
*
198-
* @see ClientBulkWrite::__construct() for supported options
199-
* @param string $databaseName Database name
200-
* @param array $options Additional options
198+
* @param BulkWriteCommand|ClientBulkWrite $bulk Assembled bulk write command or builder
199+
* @param array $options Additional options
201200
* @throws UnsupportedException if options are unsupported on the selected server
202201
* @throws InvalidArgumentException for parameter/option parsing errors
203202
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
203+
* @see ClientBulkWriteCommand::__construct() for supported options
204204
*/
205-
public function bulkWrite(BulkWriteCommand|BulkWriteCommandBuilder $bulk, array $options = []): ?BulkWriteCommandResult
205+
public function bulkWrite(BulkWriteCommand|ClientBulkWrite $bulk, array $options = []): ?BulkWriteCommandResult
206206
{
207207
if (! isset($options['writeConcern']) && ! is_in_transaction($options)) {
208208
$options['writeConcern'] = $this->writeConcern;
209209
}
210210

211-
if ($bulk instanceof BulkWriteCommandBuilder) {
211+
if ($bulk instanceof ClientBulkWrite) {
212212
$bulk = $bulk->bulkWriteCommand;
213213
}
214214

215-
$operation = new ClientBulkWrite($bulk, $options);
215+
$operation = new ClientBulkWriteCommand($bulk, $options);
216216
$server = select_server_for_write($this->manager, $options);
217217

218218
return $operation->execute($server);

Diff for: src/BulkWriteCommandBuilder.php renamed to src/ClientBulkWrite.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
use function is_bool;
2828
use function is_string;
2929

30-
final readonly class BulkWriteCommandBuilder
30+
final readonly class ClientBulkWrite
3131
{
3232
private function __construct(
3333
public BulkWriteCommand $bulkWriteCommand,

Diff for: src/Operation/ClientBulkWrite.php renamed to src/Operation/ClientBulkWriteCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
* @see \MongoDB\Client::bulkWrite()
3636
*/
37-
final class ClientBulkWrite
37+
final class ClientBulkWriteCommand
3838
{
3939
/**
4040
* Constructs a client-level bulk write operation.

Diff for: tests/SpecTests/Crud/Prose3_BulkWriteSplitsOnMaxWriteBatchSizeTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace MongoDB\Tests\SpecTests\Crud;
44

5-
use MongoDB\BulkWriteCommandBuilder;
5+
use MongoDB\ClientBulkWrite;
66
use MongoDB\Driver\Monitoring\CommandFailedEvent;
77
use MongoDB\Driver\Monitoring\CommandStartedEvent;
88
use MongoDB\Driver\Monitoring\CommandSubscriber;
@@ -30,7 +30,7 @@ public function testSplitOnMaxWriteBatchSize(): void
3030
self::assertIsInt($maxWriteBatchSize);
3131

3232
$collection = $client->selectCollection($this->getDatabaseName(), $this->getCollectionName());
33-
$bulkWrite = BulkWriteCommandBuilder::createWithCollection($collection);
33+
$bulkWrite = ClientBulkWrite::createWithCollection($collection);
3434

3535
for ($i = 0; $i < $maxWriteBatchSize + 1; ++$i) {
3636
$bulkWrite->insertOne(['a' => 'b']);

Diff for: tests/SpecTests/Crud/Prose4_BulkWriteSplitsOnMaxMessageSizeBytesTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace MongoDB\Tests\SpecTests\Crud;
44

5-
use MongoDB\BulkWriteCommandBuilder;
5+
use MongoDB\ClientBulkWrite;
66
use MongoDB\Driver\Monitoring\CommandFailedEvent;
77
use MongoDB\Driver\Monitoring\CommandStartedEvent;
88
use MongoDB\Driver\Monitoring\CommandSubscriber;
@@ -36,7 +36,7 @@ public function testSplitOnMaxWriteBatchSize(): void
3636
$document = ['a' => str_repeat('b', $maxBsonObjectSize - 500)];
3737

3838
$collection = $client->selectCollection($this->getDatabaseName(), $this->getCollectionName());
39-
$bulkWrite = BulkWriteCommandBuilder::createWithCollection($collection);
39+
$bulkWrite = ClientBulkWrite::createWithCollection($collection);
4040

4141
for ($i = 0; $i < $numModels; ++$i) {
4242
$bulkWrite->insertOne($document);

Diff for: tests/SpecTests/Crud/Prose5_BulkWriteCollectsWriteConcernErrorsAcrossBatchesTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace MongoDB\Tests\SpecTests\Crud;
44

5-
use MongoDB\BulkWriteCommandBuilder;
5+
use MongoDB\ClientBulkWrite;
66
use MongoDB\Driver\Exception\BulkWriteCommandException;
77
use MongoDB\Driver\Monitoring\CommandFailedEvent;
88
use MongoDB\Driver\Monitoring\CommandStartedEvent;
@@ -43,7 +43,7 @@ public function testCollectWriteConcernErrors(): void
4343
]);
4444

4545
$collection = $client->selectCollection($this->getDatabaseName(), $this->getCollectionName());
46-
$bulkWrite = BulkWriteCommandBuilder::createWithCollection($collection);
46+
$bulkWrite = ClientBulkWrite::createWithCollection($collection);
4747

4848
for ($i = 0; $i < $maxWriteBatchSize + 1; ++$i) {
4949
$bulkWrite->insertOne(['a' => 'b']);

Diff for: tests/SpecTests/Crud/Prose6_BulkWriteHandlesWriteErrorsAcrossBatchesTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace MongoDB\Tests\SpecTests\Crud;
44

5-
use MongoDB\BulkWriteCommandBuilder;
5+
use MongoDB\ClientBulkWrite;
66
use MongoDB\Driver\Exception\BulkWriteCommandException;
77
use MongoDB\Driver\Monitoring\CommandFailedEvent;
88
use MongoDB\Driver\Monitoring\CommandStartedEvent;
@@ -39,7 +39,7 @@ public function testOrdered(): void
3939
$collection->drop();
4040
$collection->insertOne(['_id' => 1]);
4141

42-
$bulkWrite = BulkWriteCommandBuilder::createWithCollection($collection, ['ordered' => true]);
42+
$bulkWrite = ClientBulkWrite::createWithCollection($collection, ['ordered' => true]);
4343

4444
for ($i = 0; $i < $maxWriteBatchSize + 1; ++$i) {
4545
$bulkWrite->insertOne(['_id' => 1]);
@@ -68,7 +68,7 @@ public function testUnordered(): void
6868
$collection->drop();
6969
$collection->insertOne(['_id' => 1]);
7070

71-
$bulkWrite = BulkWriteCommandBuilder::createWithCollection($collection, ['ordered' => false]);
71+
$bulkWrite = ClientBulkWrite::createWithCollection($collection, ['ordered' => false]);
7272

7373
for ($i = 0; $i < $maxWriteBatchSize + 1; ++$i) {
7474
$bulkWrite->insertOne(['_id' => 1]);

Diff for: tests/SpecTests/Crud/Prose7_BulkWriteHandlesCursorRequiringGetMoreTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace MongoDB\Tests\SpecTests\Crud;
44

5-
use MongoDB\BulkWriteCommandBuilder;
5+
use MongoDB\ClientBulkWrite;
66
use MongoDB\Driver\Monitoring\CommandFailedEvent;
77
use MongoDB\Driver\Monitoring\CommandStartedEvent;
88
use MongoDB\Driver\Monitoring\CommandSubscriber;
@@ -34,7 +34,7 @@ public function testHandlesCursor(): void
3434
$collection = $client->selectCollection($this->getDatabaseName(), $this->getCollectionName());
3535
$collection->drop();
3636

37-
$bulkWrite = BulkWriteCommandBuilder::createWithCollection($collection, ['verboseResults' => true]);
37+
$bulkWrite = ClientBulkWrite::createWithCollection($collection, ['verboseResults' => true]);
3838
$bulkWrite->updateOne(
3939
['_id' => str_repeat('a', (int) ($maxBsonObjectSize / 2))],
4040
['$set' => ['x' => 1]],

Diff for: tests/SpecTests/Crud/Prose8_BulkWriteHandlesCursorRequiringGetMoreWithinTransactionTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace MongoDB\Tests\SpecTests\Crud;
44

5-
use MongoDB\BulkWriteCommandBuilder;
5+
use MongoDB\ClientBulkWrite;
66
use MongoDB\Driver\Monitoring\CommandFailedEvent;
77
use MongoDB\Driver\Monitoring\CommandStartedEvent;
88
use MongoDB\Driver\Monitoring\CommandSubscriber;
@@ -35,7 +35,7 @@ public function testHandlesCursorWithinTransaction(): void
3535
$collection = $client->selectCollection($this->getDatabaseName(), $this->getCollectionName());
3636
$collection->drop();
3737

38-
$bulkWrite = BulkWriteCommandBuilder::createWithCollection($collection, ['verboseResults' => true]);
38+
$bulkWrite = ClientBulkWrite::createWithCollection($collection, ['verboseResults' => true]);
3939
$bulkWrite->updateOne(
4040
['_id' => str_repeat('a', (int) ($maxBsonObjectSize / 2))],
4141
['$set' => ['x' => 1]],

Diff for: tests/SpecTests/Crud/Prose9_BulkWriteHandlesGetMoreErrorTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace MongoDB\Tests\SpecTests\Crud;
44

5-
use MongoDB\BulkWriteCommandBuilder;
5+
use MongoDB\ClientBulkWrite;
66
use MongoDB\Driver\Exception\BulkWriteCommandException;
77
use MongoDB\Driver\Monitoring\CommandFailedEvent;
88
use MongoDB\Driver\Monitoring\CommandStartedEvent;
@@ -46,7 +46,7 @@ public function testHandlesGetMoreError(): void
4646
$collection = $client->selectCollection($this->getDatabaseName(), $this->getCollectionName());
4747
$collection->drop();
4848

49-
$bulkWrite = BulkWriteCommandBuilder::createWithCollection($collection, ['verboseResults' => true]);
49+
$bulkWrite = ClientBulkWrite::createWithCollection($collection, ['verboseResults' => true]);
5050
$bulkWrite->updateOne(
5151
['_id' => str_repeat('a', (int) ($maxBsonObjectSize / 2))],
5252
['$set' => ['x' => 1]],

Diff for: tests/UnifiedSpecTests/Operation.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ private function executeForClient(Client $client)
259259
assertArrayHasKey('models', $args);
260260
assertIsArray($args['models']);
261261

262-
// Options for BulkWriteCommand and Server::executeBulkWriteCommand() will be mixed
262+
// Options for ClientBulkWriteCommand and Server::executeBulkWriteCommand() will be mixed
263263
$options = array_diff_key($args, ['models' => 1]);
264264

265265
return $client->bulkWrite(

0 commit comments

Comments
 (0)