[DRIVERS-2638] Add spec tests for passing empty pipeline arrays to update and findAndModify operations Created: 26/May/23  Updated: 23/Jun/23

Status: Scheduled
Project: Drivers
Component/s: CRUD
Fix Version/s: None

Type: Task Priority: Minor - P4
Reporter: Jeremy Mikola Assignee: Jeremy Mikola
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Issue split
split to CDRIVER-4669 Add spec tests for passing empty pipe... Blocked
split to CSHARP-4687 Add spec tests for passing empty pipe... Blocked
split to CXX-2701 Add spec tests for passing empty pipe... Blocked
split to GODRIVER-2877 Add spec tests for passing empty pipe... Blocked
split to JAVA-5041 Add spec tests for passing empty pipe... Blocked
split to MOTOR-1146 Add spec tests for passing empty pipe... Blocked
split to NODE-5371 Add spec tests for passing empty pipe... Blocked
split to PHPLIB-1169 Add spec tests for passing empty pipe... Blocked
split to PYTHON-3768 Add spec tests for passing empty pipe... Blocked
split to RUBY-3282 Add spec tests for passing empty pipe... Blocked
split to RUST-1686 Add spec tests for passing empty pipe... Blocked
Related
related to PHPLIB-1129 Replace operations may inadvertently ... Closed
is related to DRIVERS-626 Add the ability to specify a pipeline... Closed
is related to DRIVERS-744 Add missing tests for aggregation pip... Closed
Driver Changes: Needed
Engineering Lead: Andreas Braun Andreas Braun
Driver Compliance:
Key Status/Resolution FixVersion
CDRIVER-4669 Blocked
CXX-2701 Blocked
CSHARP-4687 Blocked
GODRIVER-2877 Blocked
JAVA-5041 Blocked
NODE-5371 Blocked
MOTOR-1146 Blocked
PYTHON-3768 Blocked
PHPLIB-1169 Blocked
RUBY-3282 Blocked
RUST-1686 Blocked

 Description   

Summary

An empty pipeline array is a NOP for both update and findAndModify. The current CRUD spec tests for update pipelines only use non-empty pipeline arrays. We should test this to assert that drivers don't prohibit users from specifying an empty array (despite there being little reason to do so).

Consider:

> db.runCommand({ update: "foo", updates: [ { q: { _id: 1 }, u: [] } ] })
 
> db.runCommand({ findAndModify: "foo", query: { _id: 1 }, update: [] })

Motivation

Who is the affected end user?

Users wishing to execute NOP pipelines.

How does this affect the end user?

Users are potentially blocked if a driver happens to reject an empty pipeline.

How likely is it that this problem or use case will occur?

Very rare.

If the problem does occur, what are the consequences and how severe are they?

Drivers may potentially reject a valid pipeline argument.

Is this issue urgent?

No.

Is this ticket required by a downstream team?

No.

Is this ticket only for tests?

Yes.



 Comments   
Comment by Jeremy Mikola [ 07/Jun/23 ]

Note: libmongoc's _mongoc_document_is_pipeline utility function does not consider an empty array to be an update pipeline. This determines how update parameters are appended in outgoing command documents for update and findAndModify commands. See:

This seems like an intentional decision done for BC reasons. Since BSON documents and arrays are both represented using bson_t structs, empty bson_t structs would historically have been interpreted as empty replacement documents instead of NOP pipelines.

Generated at Thu Feb 08 08:26:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.