-
Notifications
You must be signed in to change notification settings - Fork 267
PHPLIB-1627: BulkWriteCommand API #1630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v2.x
Are you sure you want to change the base?
Conversation
d9351cc
to
33952f7
Compare
f2cae41
to
c4c0deb
Compare
public function insertOne(array|object $document, mixed &$id = null): self | ||
{ | ||
if ($this->codec) { | ||
$document = $this->codec->encode($document); |
Check notice
Code scanning / Psalm
PossiblyInvalidArgument Note
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type in DocumentCodec
should be relaxed to @psalm-template ObjectType of object|array
* @psalm-template ObjectType of object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply the same change as #1687
$filter = $this->builderEncoder->encodeIfSupported($filter); | ||
|
||
if ($this->codec) { | ||
$replacement = $this->codec->encode($replacement); |
Check notice
Code scanning / Psalm
PossiblyInvalidArgument Note
*/ | ||
public function execute(Server $server): BulkWriteCommandResult | ||
{ | ||
$inTransaction = isset($this->options['session']) && $this->options['session']->isInTransaction(); |
Check notice
Code scanning / Psalm
MixedMethodCall Note
|
||
$options = array_filter($this->options, fn ($value) => isset($value)); | ||
|
||
return $server->executeBulkWriteCommand($this->bulkWriteCommand, $options); |
Check notice
Code scanning / Psalm
MixedReturnStatement Note
public function insertOne(array|object $document, mixed &$id = null): self | ||
{ | ||
if ($this->codec) { | ||
$document = $this->codec->encode($document); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type in DocumentCodec
should be relaxed to @psalm-template ObjectType of object|array
* @psalm-template ObjectType of object |
The transaction spec requires certain language, and this is now expected in spec test for clientBulkWrite.
Also fixes the return type for getBuilderEncoder()
This is actually required for the union assignment in createWithCollection(). The nullable arrays were copied from the extension, but are inconsistent with other PHPLIB APIs.
Also renames the operation class to ClientBulkWriteCommand to avoid aliasing in Client.
https://jira.mongodb.org/browse/PHPLIB-1627
Requires mongodb/mongo-php-driver#1818