Merge branch 'master' of github.com:mongodb/mongo-python-driver
This commit is contained in:
commit
3feb663af3
@ -9,6 +9,9 @@ PyMongo 4.12 brings a number of changes including:
|
||||
- Support for configuring DEK cache lifetime via the ``key_expiration_ms`` argument to
|
||||
:class:`~pymongo.encryption_options.AutoEncryptionOpts`.
|
||||
- Support for $lookup in CSFLE and QE supported on MongoDB 8.1+.
|
||||
- Added index hinting support to the
|
||||
:meth:`~pymongo.asynchronous.collection.AsyncCollection.distinct` and
|
||||
:meth:`~pymongo.collection.Collection.distinct` commands.
|
||||
|
||||
Issues Resolved
|
||||
...............
|
||||
|
||||
@ -458,10 +458,10 @@ def _max_time_expired_error(exc: PyMongoError) -> bool:
|
||||
|
||||
|
||||
# From the transactions spec, all the retryable writes errors plus
|
||||
# WriteConcernFailed.
|
||||
# WriteConcernTimeout.
|
||||
_UNKNOWN_COMMIT_ERROR_CODES: frozenset = _RETRYABLE_ERROR_CODES | frozenset(
|
||||
[
|
||||
64, # WriteConcernFailed
|
||||
64, # WriteConcernTimeout
|
||||
50, # MaxTimeMSExpired
|
||||
]
|
||||
)
|
||||
|
||||
@ -3111,6 +3111,7 @@ class AsyncCollection(common.BaseObject, Generic[_DocumentType]):
|
||||
filter: Optional[Mapping[str, Any]] = None,
|
||||
session: Optional[AsyncClientSession] = None,
|
||||
comment: Optional[Any] = None,
|
||||
hint: Optional[_IndexKeyHint] = None,
|
||||
**kwargs: Any,
|
||||
) -> list:
|
||||
"""Get a list of distinct values for `key` among all documents
|
||||
@ -3138,8 +3139,15 @@ class AsyncCollection(common.BaseObject, Generic[_DocumentType]):
|
||||
:class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
|
||||
:param comment: A user-provided comment to attach to this
|
||||
command.
|
||||
:param hint: An index to use to support the query
|
||||
predicate specified either by its string name, or in the same
|
||||
format as passed to :meth:`~pymongo.asynchronous.collection.AsyncCollection.create_index`
|
||||
(e.g. ``[('field', ASCENDING)]``).
|
||||
:param kwargs: See list of options above.
|
||||
|
||||
.. versionchanged:: 4.12
|
||||
Added ``hint`` parameter.
|
||||
|
||||
.. versionchanged:: 3.6
|
||||
Added ``session`` parameter.
|
||||
|
||||
@ -3158,6 +3166,10 @@ class AsyncCollection(common.BaseObject, Generic[_DocumentType]):
|
||||
cmd.update(kwargs)
|
||||
if comment is not None:
|
||||
cmd["comment"] = comment
|
||||
if hint is not None:
|
||||
if not isinstance(hint, str):
|
||||
hint = helpers_shared._index_document(hint)
|
||||
cmd["hint"] = hint # type: ignore[assignment]
|
||||
|
||||
async def _cmd(
|
||||
session: Optional[AsyncClientSession],
|
||||
|
||||
@ -457,10 +457,10 @@ def _max_time_expired_error(exc: PyMongoError) -> bool:
|
||||
|
||||
|
||||
# From the transactions spec, all the retryable writes errors plus
|
||||
# WriteConcernFailed.
|
||||
# WriteConcernTimeout.
|
||||
_UNKNOWN_COMMIT_ERROR_CODES: frozenset = _RETRYABLE_ERROR_CODES | frozenset(
|
||||
[
|
||||
64, # WriteConcernFailed
|
||||
64, # WriteConcernTimeout
|
||||
50, # MaxTimeMSExpired
|
||||
]
|
||||
)
|
||||
|
||||
@ -3104,6 +3104,7 @@ class Collection(common.BaseObject, Generic[_DocumentType]):
|
||||
filter: Optional[Mapping[str, Any]] = None,
|
||||
session: Optional[ClientSession] = None,
|
||||
comment: Optional[Any] = None,
|
||||
hint: Optional[_IndexKeyHint] = None,
|
||||
**kwargs: Any,
|
||||
) -> list:
|
||||
"""Get a list of distinct values for `key` among all documents
|
||||
@ -3131,8 +3132,15 @@ class Collection(common.BaseObject, Generic[_DocumentType]):
|
||||
:class:`~pymongo.client_session.ClientSession`.
|
||||
:param comment: A user-provided comment to attach to this
|
||||
command.
|
||||
:param hint: An index to use to support the query
|
||||
predicate specified either by its string name, or in the same
|
||||
format as passed to :meth:`~pymongo.collection.Collection.create_index`
|
||||
(e.g. ``[('field', ASCENDING)]``).
|
||||
:param kwargs: See list of options above.
|
||||
|
||||
.. versionchanged:: 4.12
|
||||
Added ``hint`` parameter.
|
||||
|
||||
.. versionchanged:: 3.6
|
||||
Added ``session`` parameter.
|
||||
|
||||
@ -3151,6 +3159,10 @@ class Collection(common.BaseObject, Generic[_DocumentType]):
|
||||
cmd.update(kwargs)
|
||||
if comment is not None:
|
||||
cmd["comment"] = comment
|
||||
if hint is not None:
|
||||
if not isinstance(hint, str):
|
||||
hint = helpers_shared._index_document(hint)
|
||||
cmd["hint"] = hint # type: ignore[assignment]
|
||||
|
||||
def _cmd(
|
||||
session: Optional[ClientSession],
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
{
|
||||
"description": "Infinity Vector FLOAT32",
|
||||
"valid": true,
|
||||
"vector": ["-inf", 0.0, "inf"],
|
||||
"vector": [{"$numberDouble": "-Infinity"}, 0.0, {"$numberDouble": "Infinity"} ],
|
||||
"dtype_hex": "0x27",
|
||||
"dtype_alias": "FLOAT32",
|
||||
"padding": 0,
|
||||
|
||||
@ -95,29 +95,34 @@
|
||||
"ordered": false
|
||||
},
|
||||
"expectResult": {
|
||||
"insertedCount": {
|
||||
"$$unsetOrMatches": 0
|
||||
},
|
||||
"upsertedCount": {
|
||||
"$$unsetOrMatches": 0
|
||||
},
|
||||
"matchedCount": {
|
||||
"$$unsetOrMatches": 0
|
||||
},
|
||||
"modifiedCount": {
|
||||
"$$unsetOrMatches": 0
|
||||
},
|
||||
"deletedCount": {
|
||||
"$$unsetOrMatches": 0
|
||||
},
|
||||
"insertResults": {
|
||||
"$$unsetOrMatches": {}
|
||||
},
|
||||
"updateResults": {
|
||||
"$$unsetOrMatches": {}
|
||||
},
|
||||
"deleteResults": {
|
||||
"$$unsetOrMatches": {}
|
||||
"$$unsetOrMatches": {
|
||||
"acknowledged": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"insertedCount": {
|
||||
"$$unsetOrMatches": 0
|
||||
},
|
||||
"upsertedCount": {
|
||||
"$$unsetOrMatches": 0
|
||||
},
|
||||
"matchedCount": {
|
||||
"$$unsetOrMatches": 0
|
||||
},
|
||||
"modifiedCount": {
|
||||
"$$unsetOrMatches": 0
|
||||
},
|
||||
"deletedCount": {
|
||||
"$$unsetOrMatches": 0
|
||||
},
|
||||
"insertResults": {
|
||||
"$$unsetOrMatches": {}
|
||||
},
|
||||
"updateResults": {
|
||||
"$$unsetOrMatches": {}
|
||||
},
|
||||
"deleteResults": {
|
||||
"$$unsetOrMatches": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
148
test/crud/unified/bulkWrite-updateMany-pipeline.json
Normal file
148
test/crud/unified/bulkWrite-updateMany-pipeline.json
Normal file
@ -0,0 +1,148 @@
|
||||
{
|
||||
"description": "bulkWrite-updateMany-pipeline",
|
||||
"schemaVersion": "1.0",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "4.1.11"
|
||||
}
|
||||
],
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "test"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "test",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"x": 1,
|
||||
"y": 1,
|
||||
"t": {
|
||||
"u": {
|
||||
"v": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"_id": 2,
|
||||
"x": 2,
|
||||
"y": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "UpdateMany in bulk write using pipelines",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection0",
|
||||
"name": "bulkWrite",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"updateMany": {
|
||||
"filter": {},
|
||||
"update": [
|
||||
{
|
||||
"$project": {
|
||||
"x": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"matchedCount": 2,
|
||||
"modifiedCount": 2,
|
||||
"upsertedCount": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "test",
|
||||
"updates": [
|
||||
{
|
||||
"q": {},
|
||||
"u": [
|
||||
{
|
||||
"$project": {
|
||||
"x": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": true,
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"commandName": "update",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "test",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"x": 1,
|
||||
"foo": 1
|
||||
},
|
||||
{
|
||||
"_id": 2,
|
||||
"x": 2,
|
||||
"foo": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
156
test/crud/unified/bulkWrite-updateOne-pipeline.json
Normal file
156
test/crud/unified/bulkWrite-updateOne-pipeline.json
Normal file
@ -0,0 +1,156 @@
|
||||
{
|
||||
"description": "bulkWrite-updateOne-pipeline",
|
||||
"schemaVersion": "1.0",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "4.1.11"
|
||||
}
|
||||
],
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "test"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "test",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"x": 1,
|
||||
"y": 1,
|
||||
"t": {
|
||||
"u": {
|
||||
"v": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"_id": 2,
|
||||
"x": 2,
|
||||
"y": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "UpdateOne in bulk write using pipelines",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection0",
|
||||
"name": "bulkWrite",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"updateOne": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": "$t"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "test",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": "$t"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"commandName": "update",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "test",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"u": {
|
||||
"v": 1
|
||||
},
|
||||
"foo": 1
|
||||
},
|
||||
{
|
||||
"_id": 2,
|
||||
"x": 2,
|
||||
"y": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
130
test/crud/unified/findOneAndUpdate-pipeline.json
Normal file
130
test/crud/unified/findOneAndUpdate-pipeline.json
Normal file
@ -0,0 +1,130 @@
|
||||
{
|
||||
"description": "findOneAndUpdate-pipeline",
|
||||
"schemaVersion": "1.0",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "4.1.11"
|
||||
}
|
||||
],
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "test"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "test",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"x": 1,
|
||||
"y": 1,
|
||||
"t": {
|
||||
"u": {
|
||||
"v": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"_id": 2,
|
||||
"x": 2,
|
||||
"y": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "FindOneAndUpdate using pipelines",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection0",
|
||||
"name": "findOneAndUpdate",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$project": {
|
||||
"x": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"findAndModify": "test",
|
||||
"update": [
|
||||
{
|
||||
"$project": {
|
||||
"x": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"commandName": "findAndModify",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "test",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"x": 1,
|
||||
"foo": 1
|
||||
},
|
||||
{
|
||||
"_id": 2,
|
||||
"x": 2,
|
||||
"y": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
142
test/crud/unified/updateMany-pipeline.json
Normal file
142
test/crud/unified/updateMany-pipeline.json
Normal file
@ -0,0 +1,142 @@
|
||||
{
|
||||
"description": "updateMany-pipeline",
|
||||
"schemaVersion": "1.0",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "4.1.11"
|
||||
}
|
||||
],
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "test"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "test",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"x": 1,
|
||||
"y": 1,
|
||||
"t": {
|
||||
"u": {
|
||||
"v": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"_id": 2,
|
||||
"x": 2,
|
||||
"y": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "UpdateMany using pipelines",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection0",
|
||||
"name": "updateMany",
|
||||
"arguments": {
|
||||
"filter": {},
|
||||
"update": [
|
||||
{
|
||||
"$project": {
|
||||
"x": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"matchedCount": 2,
|
||||
"modifiedCount": 2,
|
||||
"upsertedCount": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "test",
|
||||
"updates": [
|
||||
{
|
||||
"q": {},
|
||||
"u": [
|
||||
{
|
||||
"$project": {
|
||||
"x": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": true,
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"commandName": "update",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "test",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"x": 1,
|
||||
"foo": 1
|
||||
},
|
||||
{
|
||||
"_id": 2,
|
||||
"x": 2,
|
||||
"foo": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
150
test/crud/unified/updateOne-pipeline.json
Normal file
150
test/crud/unified/updateOne-pipeline.json
Normal file
@ -0,0 +1,150 @@
|
||||
{
|
||||
"description": "updateOne-pipeline",
|
||||
"schemaVersion": "1.0",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "4.1.11"
|
||||
}
|
||||
],
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "test"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "test",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"x": 1,
|
||||
"y": 1,
|
||||
"t": {
|
||||
"u": {
|
||||
"v": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"_id": 2,
|
||||
"x": 2,
|
||||
"y": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "UpdateOne using pipelines",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection0",
|
||||
"name": "updateOne",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": "$t"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "test",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": "$t"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"commandName": "update",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "test",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"u": {
|
||||
"v": 1
|
||||
},
|
||||
"foo": 1
|
||||
},
|
||||
{
|
||||
"_id": 2,
|
||||
"x": 2,
|
||||
"y": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,494 +0,0 @@
|
||||
{
|
||||
"description": "updateWithPipelines",
|
||||
"schemaVersion": "1.0",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "4.1.11"
|
||||
}
|
||||
],
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "test"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "test",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"x": 1,
|
||||
"y": 1,
|
||||
"t": {
|
||||
"u": {
|
||||
"v": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"_id": 2,
|
||||
"x": 2,
|
||||
"y": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "UpdateOne using pipelines",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection0",
|
||||
"name": "updateOne",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": "$t"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "test",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": "$t"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"commandName": "update",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "test",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"u": {
|
||||
"v": 1
|
||||
},
|
||||
"foo": 1
|
||||
},
|
||||
{
|
||||
"_id": 2,
|
||||
"x": 2,
|
||||
"y": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "UpdateMany using pipelines",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection0",
|
||||
"name": "updateMany",
|
||||
"arguments": {
|
||||
"filter": {},
|
||||
"update": [
|
||||
{
|
||||
"$project": {
|
||||
"x": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"matchedCount": 2,
|
||||
"modifiedCount": 2,
|
||||
"upsertedCount": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "test",
|
||||
"updates": [
|
||||
{
|
||||
"q": {},
|
||||
"u": [
|
||||
{
|
||||
"$project": {
|
||||
"x": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": true,
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"commandName": "update",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "test",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"x": 1,
|
||||
"foo": 1
|
||||
},
|
||||
{
|
||||
"_id": 2,
|
||||
"x": 2,
|
||||
"foo": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "FindOneAndUpdate using pipelines",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection0",
|
||||
"name": "findOneAndUpdate",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$project": {
|
||||
"x": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"findAndModify": "test",
|
||||
"update": [
|
||||
{
|
||||
"$project": {
|
||||
"x": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"commandName": "findAndModify",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "test",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"x": 1,
|
||||
"foo": 1
|
||||
},
|
||||
{
|
||||
"_id": 2,
|
||||
"x": 2,
|
||||
"y": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "UpdateOne in bulk write using pipelines",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection0",
|
||||
"name": "bulkWrite",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"updateOne": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": "$t"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "test",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": "$t"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"commandName": "update",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "test",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"u": {
|
||||
"v": 1
|
||||
},
|
||||
"foo": 1
|
||||
},
|
||||
{
|
||||
"_id": 2,
|
||||
"x": 2,
|
||||
"y": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "UpdateMany in bulk write using pipelines",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection0",
|
||||
"name": "bulkWrite",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"updateMany": {
|
||||
"filter": {},
|
||||
"update": [
|
||||
{
|
||||
"$project": {
|
||||
"x": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"matchedCount": 2,
|
||||
"modifiedCount": 2,
|
||||
"upsertedCount": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "test",
|
||||
"updates": [
|
||||
{
|
||||
"q": {},
|
||||
"u": [
|
||||
{
|
||||
"$project": {
|
||||
"x": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"foo": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": true,
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"commandName": "update",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "test",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"x": 1,
|
||||
"foo": 1
|
||||
},
|
||||
{
|
||||
"_id": 2,
|
||||
"x": 2,
|
||||
"foo": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -49,10 +49,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"filename": "length-0",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -64,10 +61,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"filename": "length-0-with-empty-chunk",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -79,10 +73,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "c700ed4fdb1d27055aa3faa2c2432283",
|
||||
"filename": "length-2",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -94,10 +85,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "dd254cdc958e53abaa67da9f797125f5",
|
||||
"filename": "length-8",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
@ -197,10 +185,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"filename": "length-0-with-empty-chunk",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -212,10 +197,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "c700ed4fdb1d27055aa3faa2c2432283",
|
||||
"filename": "length-2",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -227,10 +209,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "dd254cdc958e53abaa67da9f797125f5",
|
||||
"filename": "length-8",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
@ -330,10 +309,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"filename": "length-0",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -345,10 +321,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "c700ed4fdb1d27055aa3faa2c2432283",
|
||||
"filename": "length-2",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -360,10 +333,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "dd254cdc958e53abaa67da9f797125f5",
|
||||
"filename": "length-8",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
@ -448,10 +418,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"filename": "length-0",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -463,10 +430,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"filename": "length-0-with-empty-chunk",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -478,10 +442,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "c700ed4fdb1d27055aa3faa2c2432283",
|
||||
"filename": "length-2",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
@ -554,10 +515,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"filename": "length-0",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -569,10 +527,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"filename": "length-0-with-empty-chunk",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -584,10 +539,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "c700ed4fdb1d27055aa3faa2c2432283",
|
||||
"filename": "length-2",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -599,10 +551,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "dd254cdc958e53abaa67da9f797125f5",
|
||||
"filename": "length-8",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
@ -719,10 +668,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"filename": "length-0",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -734,10 +680,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"filename": "length-0-with-empty-chunk",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -749,10 +692,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "c700ed4fdb1d27055aa3faa2c2432283",
|
||||
"filename": "length-2",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
|
||||
@ -49,10 +49,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"filename": "length-0",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -64,10 +61,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"filename": "length-0-with-empty-chunk",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -79,10 +73,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "c700ed4fdb1d27055aa3faa2c2432283",
|
||||
"filename": "length-2",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -94,10 +85,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "dd254cdc958e53abaa67da9f797125f5",
|
||||
"filename": "length-8",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -109,10 +97,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "57d83cd477bfb1ccd975ab33d827a92b",
|
||||
"filename": "length-10",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -124,9 +109,6 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "c700ed4fdb1d27055aa3faa2c2432283",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
|
||||
@ -49,10 +49,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"md5": "47ed733b8d10be225eceba344d533586",
|
||||
"filename": "abc",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -64,10 +61,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-02T00:00:00.000Z"
|
||||
},
|
||||
"md5": "b15835f133ff2e27c7cb28117bfae8f4",
|
||||
"filename": "abc",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -79,10 +73,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-03T00:00:00.000Z"
|
||||
},
|
||||
"md5": "eccbc87e4b5ce2fe28308fd9f2a7baf3",
|
||||
"filename": "abc",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -94,10 +85,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-04T00:00:00.000Z"
|
||||
},
|
||||
"md5": "f623e75af30e62bbd73d6df5b50bb7b5",
|
||||
"filename": "abc",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
@ -109,10 +97,7 @@
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-05T00:00:00.000Z"
|
||||
},
|
||||
"md5": "4c614360da93c0a041b22e537de151eb",
|
||||
"filename": "abc",
|
||||
"contentType": "application/octet-stream",
|
||||
"aliases": [],
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
|
||||
@ -470,75 +470,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "upload when contentType is provided",
|
||||
"operations": [
|
||||
{
|
||||
"name": "upload",
|
||||
"object": "bucket0",
|
||||
"arguments": {
|
||||
"filename": "filename",
|
||||
"source": {
|
||||
"$$hexBytes": "11"
|
||||
},
|
||||
"chunkSizeBytes": 4,
|
||||
"contentType": "image/jpeg"
|
||||
},
|
||||
"expectResult": {
|
||||
"$$type": "objectId"
|
||||
},
|
||||
"saveResultAsEntity": "uploadedObjectId"
|
||||
},
|
||||
{
|
||||
"name": "find",
|
||||
"object": "bucket0_files_collection",
|
||||
"arguments": {
|
||||
"filter": {}
|
||||
},
|
||||
"expectResult": [
|
||||
{
|
||||
"_id": {
|
||||
"$$matchesEntity": "uploadedObjectId"
|
||||
},
|
||||
"length": 1,
|
||||
"chunkSize": 4,
|
||||
"uploadDate": {
|
||||
"$$type": "date"
|
||||
},
|
||||
"md5": {
|
||||
"$$unsetOrMatches": "47ed733b8d10be225eceba344d533586"
|
||||
},
|
||||
"filename": "filename",
|
||||
"contentType": "image/jpeg"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "find",
|
||||
"object": "bucket0_chunks_collection",
|
||||
"arguments": {
|
||||
"filter": {}
|
||||
},
|
||||
"expectResult": [
|
||||
{
|
||||
"_id": {
|
||||
"$$type": "objectId"
|
||||
},
|
||||
"files_id": {
|
||||
"$$matchesEntity": "uploadedObjectId"
|
||||
},
|
||||
"n": 0,
|
||||
"data": {
|
||||
"$binary": {
|
||||
"base64": "EQ==",
|
||||
"subType": "00"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "upload when metadata is provided",
|
||||
"operations": [
|
||||
|
||||
@ -739,7 +739,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "InsertOne fails after WriteConcernError WriteConcernFailed",
|
||||
"description": "InsertOne fails after WriteConcernError WriteConcernTimeout",
|
||||
"operations": [
|
||||
{
|
||||
"name": "failPoint",
|
||||
@ -757,7 +757,6 @@
|
||||
],
|
||||
"writeConcernError": {
|
||||
"code": 64,
|
||||
"codeName": "WriteConcernFailed",
|
||||
"errmsg": "waiting for replication timed out",
|
||||
"errInfo": {
|
||||
"wtimeout": true
|
||||
|
||||
@ -16,12 +16,11 @@ from __future__ import annotations
|
||||
|
||||
import binascii
|
||||
import codecs
|
||||
import json
|
||||
import struct
|
||||
from pathlib import Path
|
||||
from test import unittest
|
||||
|
||||
from bson import decode, encode
|
||||
from bson import decode, encode, json_util
|
||||
from bson.binary import Binary, BinaryVectorDtype
|
||||
|
||||
_TEST_PATH = Path(__file__).parent / "bson_binary_vector"
|
||||
@ -62,9 +61,6 @@ def create_test(case_spec):
|
||||
cB_exp = binascii.unhexlify(canonical_bson_exp.encode("utf8"))
|
||||
decoded_doc = decode(cB_exp)
|
||||
binary_obs = decoded_doc[test_key]
|
||||
# Handle special float cases like '-inf'
|
||||
if dtype_exp in [BinaryVectorDtype.FLOAT32]:
|
||||
vector_exp = [float(x) for x in vector_exp]
|
||||
|
||||
# Test round-tripping canonical bson.
|
||||
self.assertEqual(encode(decoded_doc), cB_exp, description)
|
||||
@ -104,7 +100,7 @@ def create_test(case_spec):
|
||||
def create_tests():
|
||||
for filename in _TEST_PATH.glob("*.json"):
|
||||
with codecs.open(str(filename), encoding="utf-8") as test_file:
|
||||
test_method = create_test(json.load(test_file))
|
||||
test_method = create_test(json_util.loads(test_file.read()))
|
||||
setattr(TestBSONBinaryVector, "test_" + filename.stem, test_method)
|
||||
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "commitTransaction is retried after WriteConcernFailed timeout error",
|
||||
"description": "commitTransaction is retried after WriteConcernTimeout timeout error",
|
||||
"operations": [
|
||||
{
|
||||
"name": "failPoint",
|
||||
@ -74,7 +74,6 @@
|
||||
],
|
||||
"writeConcernError": {
|
||||
"code": 64,
|
||||
"codeName": "WriteConcernFailed",
|
||||
"errmsg": "waiting for replication timed out",
|
||||
"errInfo": {
|
||||
"wtimeout": true
|
||||
@ -236,7 +235,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "commitTransaction is retried after WriteConcernFailed non-timeout error",
|
||||
"description": "commitTransaction is retried after WriteConcernTimeout non-timeout error",
|
||||
"operations": [
|
||||
{
|
||||
"name": "failPoint",
|
||||
@ -254,7 +253,6 @@
|
||||
],
|
||||
"writeConcernError": {
|
||||
"code": 64,
|
||||
"codeName": "WriteConcernFailed",
|
||||
"errmsg": "multiple errors reported"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1176,7 +1176,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "add UnknownTransactionCommitResult label to writeConcernError WriteConcernFailed",
|
||||
"description": "add UnknownTransactionCommitResult label to writeConcernError WriteConcernTimeout",
|
||||
"operations": [
|
||||
{
|
||||
"object": "testRunner",
|
||||
@ -1338,7 +1338,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "add UnknownTransactionCommitResult label to writeConcernError WriteConcernFailed with wtimeout",
|
||||
"description": "add UnknownTransactionCommitResult label to writeConcernError WriteConcernTimeout with wtimeout",
|
||||
"operations": [
|
||||
{
|
||||
"object": "testRunner",
|
||||
@ -1356,7 +1356,6 @@
|
||||
],
|
||||
"writeConcernError": {
|
||||
"code": 64,
|
||||
"codeName": "WriteConcernFailed",
|
||||
"errmsg": "waiting for replication timed out",
|
||||
"errInfo": {
|
||||
"wtimeout": true
|
||||
|
||||
@ -0,0 +1,174 @@
|
||||
{
|
||||
"description": "operator-type-number_alias",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "test"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "coll0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "test",
|
||||
"documents": []
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "type number alias matches int32",
|
||||
"operations": [
|
||||
{
|
||||
"name": "insertOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"document": {
|
||||
"_id": 1,
|
||||
"x": {
|
||||
"$numberInt": "2147483647"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "find",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"limit": 1
|
||||
},
|
||||
"expectResult": [
|
||||
{
|
||||
"_id": 1,
|
||||
"x": {
|
||||
"$$type": "number"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "type number alias matches int64",
|
||||
"operations": [
|
||||
{
|
||||
"name": "insertOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"document": {
|
||||
"_id": 1,
|
||||
"x": {
|
||||
"$numberLong": "9223372036854775807"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "find",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"limit": 1
|
||||
},
|
||||
"expectResult": [
|
||||
{
|
||||
"_id": 1,
|
||||
"x": {
|
||||
"$$type": "number"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "type number alias matches double",
|
||||
"operations": [
|
||||
{
|
||||
"name": "insertOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"document": {
|
||||
"_id": 1,
|
||||
"x": {
|
||||
"$numberDouble": "2.71828"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "find",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"limit": 1
|
||||
},
|
||||
"expectResult": [
|
||||
{
|
||||
"_id": 1,
|
||||
"x": {
|
||||
"$$type": "number"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "type number alias matches decimal128",
|
||||
"operations": [
|
||||
{
|
||||
"name": "insertOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"document": {
|
||||
"_id": 1,
|
||||
"x": {
|
||||
"$numberDecimal": "3.14159"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "find",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"limit": 1
|
||||
},
|
||||
"expectResult": [
|
||||
{
|
||||
"_id": 1,
|
||||
"x": {
|
||||
"$$type": "number"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -363,6 +363,7 @@ BSON_TYPE_ALIAS_MAP = {
|
||||
"decimal": (Decimal128,),
|
||||
"maxKey": (MaxKey,),
|
||||
"minKey": (MinKey,),
|
||||
"number": (float, int, Int64, Decimal128),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user