PYTHON-2556 Disable dots and dollars validation
This commit is contained in:
parent
4c77d7c855
commit
640fee9d5d
@ -6,6 +6,9 @@ Changes in Version 4.0
|
||||
|
||||
.. warning:: PyMongo 4.0 drops support for Python 2.7, 3.4, and 3.5.
|
||||
|
||||
.. warning:: PyMongo now allows insertion of documents with keys that include
|
||||
dots ('.') or start with dollar signs ('$').
|
||||
|
||||
PyMongo 4.0 brings a number of improvements as well as some backward breaking
|
||||
changes. For example, all APIs deprecated in PyMongo 3.X have been removed.
|
||||
Be sure to read the changes listed below and the :doc:`migrate-to-pymongo4`
|
||||
|
||||
@ -644,7 +644,7 @@ class Collection(common.BaseObject):
|
||||
write_concern = self._write_concern_for(session)
|
||||
return InsertOneResult(
|
||||
self._insert_one(
|
||||
document, ordered=True, check_keys=True,
|
||||
document, ordered=True, check_keys=False,
|
||||
write_concern=write_concern, op_id=None,
|
||||
bypass_doc_val=bypass_document_validation, session=session),
|
||||
write_concern.acknowledged)
|
||||
@ -712,7 +712,7 @@ class Collection(common.BaseObject):
|
||||
return InsertManyResult(inserted_ids, write_concern.acknowledged)
|
||||
|
||||
def _update(self, sock_info, criteria, document, upsert=False,
|
||||
check_keys=True, multi=False,
|
||||
check_keys=False, multi=False,
|
||||
write_concern=None, op_id=None, ordered=True,
|
||||
bypass_doc_val=False, collation=None, array_filters=None,
|
||||
hint=None, session=None, retryable_write=False):
|
||||
@ -799,7 +799,7 @@ class Collection(common.BaseObject):
|
||||
|
||||
def _update_retryable(
|
||||
self, criteria, document, upsert=False,
|
||||
check_keys=True, multi=False,
|
||||
check_keys=False, multi=False,
|
||||
write_concern=None, op_id=None, ordered=True,
|
||||
bypass_doc_val=False, collation=None, array_filters=None,
|
||||
hint=None, session=None):
|
||||
|
||||
@ -938,7 +938,7 @@ class _BulkWriteContext(object):
|
||||
@property
|
||||
def check_keys(self):
|
||||
"""Should we check keys for this operation type?"""
|
||||
return self.op_type == _INSERT
|
||||
return False
|
||||
|
||||
@property
|
||||
def max_bson_size(self):
|
||||
|
||||
@ -17,6 +17,26 @@
|
||||
"description": "Single-character key subdoc",
|
||||
"canonical_bson": "160000000378000E0000000261000200000062000000",
|
||||
"canonical_extjson": "{\"x\" : {\"a\" : \"b\"}}"
|
||||
},
|
||||
{
|
||||
"description": "Dollar-prefixed key in sub-document",
|
||||
"canonical_bson": "170000000378000F000000022461000200000062000000",
|
||||
"canonical_extjson": "{\"x\" : {\"$a\" : \"b\"}}"
|
||||
},
|
||||
{
|
||||
"description": "Dollar as key in sub-document",
|
||||
"canonical_bson": "160000000378000E0000000224000200000061000000",
|
||||
"canonical_extjson": "{\"x\" : {\"$\" : \"a\"}}"
|
||||
},
|
||||
{
|
||||
"description": "Dotted key in sub-document",
|
||||
"canonical_bson": "180000000378001000000002612E62000200000063000000",
|
||||
"canonical_extjson": "{\"x\" : {\"a.b\" : \"c\"}}"
|
||||
},
|
||||
{
|
||||
"description": "Dot as key in sub-document",
|
||||
"canonical_bson": "160000000378000E000000022E000200000061000000",
|
||||
"canonical_extjson": "{\"x\" : {\".\" : \"a\"}}"
|
||||
}
|
||||
],
|
||||
"decodeErrors": [
|
||||
|
||||
@ -3,9 +3,24 @@
|
||||
"bson_type": "0x00",
|
||||
"valid": [
|
||||
{
|
||||
"description": "Document with keys that start with $",
|
||||
"description": "Dollar-prefixed key in top-level document",
|
||||
"canonical_bson": "0F00000010246B6579002A00000000",
|
||||
"canonical_extjson": "{\"$key\": {\"$numberInt\": \"42\"}}"
|
||||
},
|
||||
{
|
||||
"description": "Dollar as key in top-level document",
|
||||
"canonical_bson": "0E00000002240002000000610000",
|
||||
"canonical_extjson": "{\"$\": \"a\"}"
|
||||
},
|
||||
{
|
||||
"description": "Dotted key in top-level document",
|
||||
"canonical_bson": "1000000002612E620002000000630000",
|
||||
"canonical_extjson": "{\"a.b\": \"c\"}"
|
||||
},
|
||||
{
|
||||
"description": "Dot as key in top-level document",
|
||||
"canonical_bson": "0E000000022E0002000000610000",
|
||||
"canonical_extjson": "{\".\": \"a\"}"
|
||||
}
|
||||
],
|
||||
"decodeErrors": [
|
||||
@ -199,14 +214,6 @@
|
||||
"description": "Bad $date (extra field)",
|
||||
"string": "{\"a\" : {\"$date\" : {\"$numberLong\" : \"1356351330501\"}, \"unrelated\": true}}"
|
||||
},
|
||||
{
|
||||
"description": "Bad DBRef (ref is number, not string)",
|
||||
"string": "{\"x\" : {\"$ref\" : 42, \"$id\" : \"abc\"}}"
|
||||
},
|
||||
{
|
||||
"description": "Bad DBRef (db is number, not string)",
|
||||
"string": "{\"x\" : {\"$ref\" : \"a\", \"$id\" : \"abc\", \"$db\" : 42}}"
|
||||
},
|
||||
{
|
||||
"description": "Bad $minKey (boolean, not integer)",
|
||||
"string": "{\"a\" : {\"$minKey\" : true}}"
|
||||
|
||||
374
test/crud/unified/bulkWrite-insertOne-dots_and_dollars.json
Normal file
374
test/crud/unified/bulkWrite-insertOne-dots_and_dollars.json
Normal file
@ -0,0 +1,374 @@
|
||||
{
|
||||
"description": "bulkWrite-insertOne-dots_and_dollars",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "coll0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": []
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "Inserting document with top-level dollar-prefixed key on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"insertOne": {
|
||||
"document": {
|
||||
"_id": 1,
|
||||
"$a": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"deletedCount": 0,
|
||||
"insertedCount": 1,
|
||||
"insertedIds": {
|
||||
"$$unsetOrMatches": {
|
||||
"0": 1
|
||||
}
|
||||
},
|
||||
"matchedCount": 0,
|
||||
"modifiedCount": 0,
|
||||
"upsertedCount": 0,
|
||||
"upsertedIds": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll0",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"$a": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"$a": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Inserting document with top-level dollar-prefixed key on pre-5.0 server yields server-side error",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"maxServerVersion": "4.99"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"insertOne": {
|
||||
"document": {
|
||||
"_id": 1,
|
||||
"$a": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectError": {
|
||||
"isClientError": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll0",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"$a": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Inserting document with top-level dotted key",
|
||||
"operations": [
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"insertOne": {
|
||||
"document": {
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"deletedCount": 0,
|
||||
"insertedCount": 1,
|
||||
"insertedIds": {
|
||||
"$$unsetOrMatches": {
|
||||
"0": 1
|
||||
}
|
||||
},
|
||||
"matchedCount": 0,
|
||||
"modifiedCount": 0,
|
||||
"upsertedCount": 0,
|
||||
"upsertedIds": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll0",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Inserting document with dollar-prefixed key in embedded doc",
|
||||
"operations": [
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"insertOne": {
|
||||
"document": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"deletedCount": 0,
|
||||
"insertedCount": 1,
|
||||
"insertedIds": {
|
||||
"$$unsetOrMatches": {
|
||||
"0": 1
|
||||
}
|
||||
},
|
||||
"matchedCount": 0,
|
||||
"modifiedCount": 0,
|
||||
"upsertedCount": 0,
|
||||
"upsertedIds": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll0",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Inserting document with dotted key in embedded doc",
|
||||
"operations": [
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"insertOne": {
|
||||
"document": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"deletedCount": 0,
|
||||
"insertedCount": 1,
|
||||
"insertedIds": {
|
||||
"$$unsetOrMatches": {
|
||||
"0": 1
|
||||
}
|
||||
},
|
||||
"matchedCount": 0,
|
||||
"modifiedCount": 0,
|
||||
"upsertedCount": 0,
|
||||
"upsertedIds": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll0",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
532
test/crud/unified/bulkWrite-replaceOne-dots_and_dollars.json
Normal file
532
test/crud/unified/bulkWrite-replaceOne-dots_and_dollars.json
Normal file
@ -0,0 +1,532 @@
|
||||
{
|
||||
"description": "bulkWrite-replaceOne-dots_and_dollars",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "coll0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "Replacing document with top-level dotted key on 3.6+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "3.6"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"replaceOne": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"replacement": {
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"deletedCount": 0,
|
||||
"insertedCount": 0,
|
||||
"insertedIds": {
|
||||
"$$unsetOrMatches": {}
|
||||
},
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0,
|
||||
"upsertedIds": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": {
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
},
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Replacing document with top-level dotted key on pre-3.6 server yields server-side error",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"maxServerVersion": "3.4.99"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"replaceOne": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"replacement": {
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectError": {
|
||||
"isClientError": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": {
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
},
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Replacing document with dollar-prefixed key in embedded doc on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"replaceOne": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"replacement": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"deletedCount": 0,
|
||||
"insertedCount": 0,
|
||||
"insertedIds": {
|
||||
"$$unsetOrMatches": {}
|
||||
},
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0,
|
||||
"upsertedIds": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
},
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Replacing document with dollar-prefixed key in embedded doc on pre-5.0 server yields server-side error",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"maxServerVersion": "4.99"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"replaceOne": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"replacement": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectError": {
|
||||
"isClientError": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
},
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Replacing document with dotted key in embedded doc on 3.6+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "3.6"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"replaceOne": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"replacement": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"deletedCount": 0,
|
||||
"insertedCount": 0,
|
||||
"insertedIds": {
|
||||
"$$unsetOrMatches": {}
|
||||
},
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0,
|
||||
"upsertedIds": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
},
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Replacing document with dotted key in embedded doc on pre-3.6 server yields server-side error",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"maxServerVersion": "3.4.99"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"replaceOne": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"replacement": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectError": {
|
||||
"isClientError": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
},
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"description": "bulkWrite-update-validation",
|
||||
"schemaVersion": "1.1",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
@ -14,21 +14,21 @@
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-v2"
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "crud-v2"
|
||||
"collectionName": "coll0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "crud-v2",
|
||||
"databaseName": "crud-v2",
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
@ -50,8 +50,8 @@
|
||||
"description": "BulkWrite replaceOne prohibits atomic modifiers",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection0",
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
@ -69,7 +69,7 @@
|
||||
]
|
||||
},
|
||||
"expectError": {
|
||||
"isError": true
|
||||
"isClientError": true
|
||||
}
|
||||
}
|
||||
],
|
||||
@ -81,8 +81,8 @@
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "crud-v2",
|
||||
"databaseName": "crud-v2",
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
@ -104,8 +104,8 @@
|
||||
"description": "BulkWrite updateOne requires atomic modifiers",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection0",
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
@ -121,7 +121,7 @@
|
||||
]
|
||||
},
|
||||
"expectError": {
|
||||
"isError": true
|
||||
"isClientError": true
|
||||
}
|
||||
}
|
||||
],
|
||||
@ -133,8 +133,8 @@
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "crud-v2",
|
||||
"databaseName": "crud-v2",
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
@ -156,8 +156,8 @@
|
||||
"description": "BulkWrite updateMany requires atomic modifiers",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection0",
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
@ -175,7 +175,7 @@
|
||||
]
|
||||
},
|
||||
"expectError": {
|
||||
"isError": true
|
||||
"isClientError": true
|
||||
}
|
||||
}
|
||||
],
|
||||
@ -187,8 +187,8 @@
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "crud-v2",
|
||||
"databaseName": "crud-v2",
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
|
||||
452
test/crud/unified/bulkWrite-updateMany-dots_and_dollars.json
Normal file
452
test/crud/unified/bulkWrite-updateMany-dots_and_dollars.json
Normal file
@ -0,0 +1,452 @@
|
||||
{
|
||||
"description": "bulkWrite-updateMany-dots_and_dollars",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "coll0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "Updating document to set top-level dollar-prefixed key on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"updateMany": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"deletedCount": 0,
|
||||
"insertedCount": 0,
|
||||
"insertedIds": {
|
||||
"$$unsetOrMatches": {}
|
||||
},
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0,
|
||||
"upsertedIds": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": true,
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {},
|
||||
"$a": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Updating document to set top-level dotted key on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"updateMany": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"deletedCount": 0,
|
||||
"insertedCount": 0,
|
||||
"insertedIds": {
|
||||
"$$unsetOrMatches": {}
|
||||
},
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0,
|
||||
"upsertedIds": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": true,
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {},
|
||||
"a.b": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Updating document to set dollar-prefixed key in embedded doc on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"updateMany": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"deletedCount": 0,
|
||||
"insertedCount": 0,
|
||||
"insertedIds": {
|
||||
"$$unsetOrMatches": {}
|
||||
},
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0,
|
||||
"upsertedIds": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": true,
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {
|
||||
"$a": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Updating document to set dotted key in embedded doc on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"updateMany": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"deletedCount": 0,
|
||||
"insertedCount": 0,
|
||||
"insertedIds": {
|
||||
"$$unsetOrMatches": {}
|
||||
},
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0,
|
||||
"upsertedIds": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": true,
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {
|
||||
"a.b": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
460
test/crud/unified/bulkWrite-updateOne-dots_and_dollars.json
Normal file
460
test/crud/unified/bulkWrite-updateOne-dots_and_dollars.json
Normal file
@ -0,0 +1,460 @@
|
||||
{
|
||||
"description": "bulkWrite-updateOne-dots_and_dollars",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "coll0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "Updating document to set top-level dollar-prefixed key on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"updateOne": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"deletedCount": 0,
|
||||
"insertedCount": 0,
|
||||
"insertedIds": {
|
||||
"$$unsetOrMatches": {}
|
||||
},
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0,
|
||||
"upsertedIds": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {},
|
||||
"$a": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Updating document to set top-level dotted key on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"updateOne": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"deletedCount": 0,
|
||||
"insertedCount": 0,
|
||||
"insertedIds": {
|
||||
"$$unsetOrMatches": {}
|
||||
},
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0,
|
||||
"upsertedIds": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {},
|
||||
"a.b": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Updating document to set dollar-prefixed key in embedded doc on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"updateOne": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"deletedCount": 0,
|
||||
"insertedCount": 0,
|
||||
"insertedIds": {
|
||||
"$$unsetOrMatches": {}
|
||||
},
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0,
|
||||
"upsertedIds": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {
|
||||
"$a": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Updating document to set dotted key in embedded doc on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"updateOne": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"deletedCount": 0,
|
||||
"insertedCount": 0,
|
||||
"insertedIds": {
|
||||
"$$unsetOrMatches": {}
|
||||
},
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0,
|
||||
"upsertedIds": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {
|
||||
"a.b": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
430
test/crud/unified/findOneAndReplace-dots_and_dollars.json
Normal file
430
test/crud/unified/findOneAndReplace-dots_and_dollars.json
Normal file
@ -0,0 +1,430 @@
|
||||
{
|
||||
"description": "findOneAndReplace-dots_and_dollars",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "coll0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "Replacing document with top-level dotted key on 3.6+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "3.6"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "findOneAndReplace",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"replacement": {
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
}
|
||||
},
|
||||
"expectResult": {
|
||||
"_id": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"findAndModify": "coll0",
|
||||
"query": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": {
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
},
|
||||
"new": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Replacing document with top-level dotted key on pre-3.6 server yields server-side error",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"maxServerVersion": "3.4.99"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "findOneAndReplace",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"replacement": {
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"isClientError": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"findAndModify": "coll0",
|
||||
"query": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": {
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
},
|
||||
"new": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Replacing document with dollar-prefixed key in embedded doc on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "findOneAndReplace",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"replacement": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"expectResult": {
|
||||
"_id": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"findAndModify": "coll0",
|
||||
"query": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
},
|
||||
"new": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Replacing document with dollar-prefixed key in embedded doc on pre-5.0 server yields server-side error",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"maxServerVersion": "4.99"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "findOneAndReplace",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"replacement": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"isClientError": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"findAndModify": "coll0",
|
||||
"query": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
},
|
||||
"new": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Replacing document with dotted key in embedded doc on 3.6+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "3.6"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "findOneAndReplace",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"replacement": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"expectResult": {
|
||||
"_id": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"findAndModify": "coll0",
|
||||
"query": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
},
|
||||
"new": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Replacing document with dotted key in embedded doc on pre-3.6 server yields server-side error",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"maxServerVersion": "3.4.99"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "findOneAndReplace",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"replacement": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"isClientError": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"findAndModify": "coll0",
|
||||
"query": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
},
|
||||
"new": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
380
test/crud/unified/findOneAndUpdate-dots_and_dollars.json
Normal file
380
test/crud/unified/findOneAndUpdate-dots_and_dollars.json
Normal file
@ -0,0 +1,380 @@
|
||||
{
|
||||
"description": "findOneAndUpdate-dots_and_dollars",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "coll0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "Updating document to set top-level dollar-prefixed key on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "findOneAndUpdate",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"_id": 1,
|
||||
"foo": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"findAndModify": "coll0",
|
||||
"query": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"new": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {},
|
||||
"$a": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Updating document to set top-level dotted key on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "findOneAndUpdate",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"_id": 1,
|
||||
"foo": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"findAndModify": "coll0",
|
||||
"query": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"new": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {},
|
||||
"a.b": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Updating document to set dollar-prefixed key in embedded doc on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "findOneAndUpdate",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"_id": 1,
|
||||
"foo": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"findAndModify": "coll0",
|
||||
"query": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"new": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {
|
||||
"$a": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Updating document to set dotted key in embedded doc on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "findOneAndUpdate",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"_id": 1,
|
||||
"foo": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"findAndModify": "coll0",
|
||||
"query": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"new": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {
|
||||
"a.b": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
334
test/crud/unified/insertMany-dots_and_dollars.json
Normal file
334
test/crud/unified/insertMany-dots_and_dollars.json
Normal file
@ -0,0 +1,334 @@
|
||||
{
|
||||
"description": "insertMany-dots_and_dollars",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "coll0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": []
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "Inserting document with top-level dollar-prefixed key on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "insertMany",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"$a": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"insertedCount": 1,
|
||||
"insertedIds": {
|
||||
"$$unsetOrMatches": {
|
||||
"0": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll0",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"$a": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"$a": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Inserting document with top-level dollar-prefixed key on pre-5.0 server yields server-side error",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"maxServerVersion": "4.99"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "insertMany",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"$a": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectError": {
|
||||
"isClientError": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll0",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"$a": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Inserting document with top-level dotted key",
|
||||
"operations": [
|
||||
{
|
||||
"name": "insertMany",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"insertedCount": 1,
|
||||
"insertedIds": {
|
||||
"$$unsetOrMatches": {
|
||||
"0": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll0",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Inserting document with dollar-prefixed key in embedded doc",
|
||||
"operations": [
|
||||
{
|
||||
"name": "insertMany",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"insertedCount": 1,
|
||||
"insertedIds": {
|
||||
"$$unsetOrMatches": {
|
||||
"0": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll0",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Inserting document with dotted key in embedded doc",
|
||||
"operations": [
|
||||
{
|
||||
"name": "insertMany",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"insertedCount": 1,
|
||||
"insertedIds": {
|
||||
"$$unsetOrMatches": {
|
||||
"0": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll0",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
606
test/crud/unified/insertOne-dots_and_dollars.json
Normal file
606
test/crud/unified/insertOne-dots_and_dollars.json
Normal file
@ -0,0 +1,606 @@
|
||||
{
|
||||
"description": "insertOne-dots_and_dollars",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "coll0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection1",
|
||||
"database": "database0",
|
||||
"collectionName": "coll1",
|
||||
"collectionOptions": {
|
||||
"writeConcern": {
|
||||
"w": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": []
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "Inserting document with top-level dollar-prefixed key on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "insertOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"document": {
|
||||
"_id": 1,
|
||||
"$a": 1
|
||||
}
|
||||
},
|
||||
"expectResult": {
|
||||
"insertedCount": 1,
|
||||
"insertedId": {
|
||||
"$$unsetOrMatches": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll0",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"$a": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"$a": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Inserting document with top-level dollar-prefixed key on pre-5.0 server yields server-side error",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"maxServerVersion": "4.99"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "insertOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"document": {
|
||||
"_id": 1,
|
||||
"$a": 1
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"isClientError": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll0",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"$a": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Inserting document with top-level dotted key",
|
||||
"operations": [
|
||||
{
|
||||
"name": "insertOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"document": {
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
}
|
||||
},
|
||||
"expectResult": {
|
||||
"insertedCount": 1,
|
||||
"insertedId": {
|
||||
"$$unsetOrMatches": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll0",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Inserting document with dollar-prefixed key in embedded doc",
|
||||
"operations": [
|
||||
{
|
||||
"name": "insertOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"document": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"expectResult": {
|
||||
"insertedCount": 1,
|
||||
"insertedId": {
|
||||
"$$unsetOrMatches": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll0",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Inserting document with dotted key in embedded doc",
|
||||
"operations": [
|
||||
{
|
||||
"name": "insertOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"document": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"expectResult": {
|
||||
"insertedCount": 1,
|
||||
"insertedId": {
|
||||
"$$unsetOrMatches": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll0",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Inserting document with dollar-prefixed key in _id yields server-side error",
|
||||
"operations": [
|
||||
{
|
||||
"name": "insertOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"document": {
|
||||
"_id": {
|
||||
"$a": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"isClientError": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll0",
|
||||
"documents": [
|
||||
{
|
||||
"_id": {
|
||||
"$a": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Inserting document with dotted key in _id on 3.6+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "3.6"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "insertOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"document": {
|
||||
"_id": {
|
||||
"a.b": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"expectResult": {
|
||||
"insertedCount": 1,
|
||||
"insertedId": {
|
||||
"$$unsetOrMatches": {
|
||||
"a.b": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll0",
|
||||
"documents": [
|
||||
{
|
||||
"_id": {
|
||||
"a.b": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": {
|
||||
"a.b": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Inserting document with dotted key in _id on pre-3.6 server yields server-side error",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"maxServerVersion": "3.4.99"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "insertOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"document": {
|
||||
"_id": {
|
||||
"a.b": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"isClientError": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll0",
|
||||
"documents": [
|
||||
{
|
||||
"_id": {
|
||||
"a.b": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Inserting document with DBRef-like keys",
|
||||
"operations": [
|
||||
{
|
||||
"name": "insertOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"document": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$db": "foo"
|
||||
}
|
||||
}
|
||||
},
|
||||
"expectResult": {
|
||||
"insertedCount": 1,
|
||||
"insertedId": {
|
||||
"$$unsetOrMatches": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll0",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$db": "foo"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$db": "foo"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Unacknowledged write using dollar-prefixed or dotted keys may be silently rejected on pre-5.0 server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"maxServerVersion": "4.99"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "insertOne",
|
||||
"object": "collection1",
|
||||
"arguments": {
|
||||
"document": {
|
||||
"_id": {
|
||||
"$a": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"expectResult": {
|
||||
"acknowledged": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"insert": "coll1",
|
||||
"documents": [
|
||||
{
|
||||
"_id": {
|
||||
"$a": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"writeConcern": {
|
||||
"w": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
567
test/crud/unified/replaceOne-dots_and_dollars.json
Normal file
567
test/crud/unified/replaceOne-dots_and_dollars.json
Normal file
@ -0,0 +1,567 @@
|
||||
{
|
||||
"description": "replaceOne-dots_and_dollars",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "coll0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection1",
|
||||
"database": "database0",
|
||||
"collectionName": "coll1",
|
||||
"collectionOptions": {
|
||||
"writeConcern": {
|
||||
"w": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "Replacing document with top-level dotted key on 3.6+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "3.6"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "replaceOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"replacement": {
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
}
|
||||
},
|
||||
"expectResult": {
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": {
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
},
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Replacing document with top-level dotted key on pre-3.6 server yields server-side error",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"maxServerVersion": "3.4.99"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "replaceOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"replacement": {
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"isClientError": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": {
|
||||
"_id": 1,
|
||||
"a.b": 1
|
||||
},
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Replacing document with dollar-prefixed key in embedded doc on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "replaceOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"replacement": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"expectResult": {
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
},
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Replacing document with dollar-prefixed key in embedded doc on pre-5.0 server yields server-side error",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"maxServerVersion": "4.99"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "replaceOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"replacement": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"isClientError": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
},
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Replacing document with dotted key in embedded doc on 3.6+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "3.6"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "replaceOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"replacement": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"expectResult": {
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
},
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Replacing document with dotted key in embedded doc on pre-3.6 server yields server-side error",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"maxServerVersion": "3.4.99"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "replaceOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"replacement": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"isClientError": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"b.c": 1
|
||||
}
|
||||
},
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Unacknowledged write using dollar-prefixed or dotted keys may be silently rejected on pre-5.0 server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"maxServerVersion": "4.99"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "replaceOne",
|
||||
"object": "collection1",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"replacement": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"expectResult": {
|
||||
"acknowledged": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll1",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": {
|
||||
"_id": 1,
|
||||
"a": {
|
||||
"$b": 1
|
||||
}
|
||||
},
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"writeConcern": {
|
||||
"w": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"description": "replaceOne-validation",
|
||||
"schemaVersion": "1.1",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
@ -14,21 +14,21 @@
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-v2"
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "crud-v2"
|
||||
"collectionName": "coll0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "crud-v2",
|
||||
"databaseName": "crud-v2",
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
@ -42,8 +42,8 @@
|
||||
"description": "ReplaceOne prohibits atomic modifiers",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection0",
|
||||
"name": "replaceOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
@ -55,7 +55,7 @@
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"isError": true
|
||||
"isClientError": true
|
||||
}
|
||||
}
|
||||
],
|
||||
@ -67,8 +67,8 @@
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "crud-v2",
|
||||
"databaseName": "crud-v2",
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
|
||||
404
test/crud/unified/updateMany-dots_and_dollars.json
Normal file
404
test/crud/unified/updateMany-dots_and_dollars.json
Normal file
@ -0,0 +1,404 @@
|
||||
{
|
||||
"description": "updateMany-dots_and_dollars",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "coll0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "Updating document to set top-level dollar-prefixed key on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "updateMany",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": true,
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {},
|
||||
"$a": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Updating document to set top-level dotted key on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "updateMany",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": true,
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {},
|
||||
"a.b": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Updating document to set dollar-prefixed key in embedded doc on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "updateMany",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": true,
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {
|
||||
"$a": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Updating document to set dotted key in embedded doc on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "updateMany",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": true,
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {
|
||||
"a.b": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"description": "updateMany-validation",
|
||||
"schemaVersion": "1.1",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
@ -14,21 +14,21 @@
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-v2"
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "crud-v2"
|
||||
"collectionName": "coll0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "crud-v2",
|
||||
"databaseName": "crud-v2",
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
@ -47,11 +47,11 @@
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "UpdateOne requires atomic modifiers",
|
||||
"description": "UpdateMany requires atomic modifiers",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection0",
|
||||
"name": "updateMany",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": {
|
||||
@ -63,7 +63,7 @@
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"isError": true
|
||||
"isClientError": true
|
||||
}
|
||||
}
|
||||
],
|
||||
@ -75,8 +75,8 @@
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "crud-v2",
|
||||
"databaseName": "crud-v2",
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
|
||||
412
test/crud/unified/updateOne-dots_and_dollars.json
Normal file
412
test/crud/unified/updateOne-dots_and_dollars.json
Normal file
@ -0,0 +1,412 @@
|
||||
{
|
||||
"description": "updateOne-dots_and_dollars",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "coll0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "Updating document to set top-level dollar-prefixed key on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "updateOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {},
|
||||
"$a": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Updating document to set top-level dotted key on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "updateOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$replaceWith": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$$ROOT"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {},
|
||||
"a.b": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Updating document to set dollar-prefixed key in embedded doc on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "updateOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "$a"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {
|
||||
"$a": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Updating document to set dotted key in embedded doc on 5.0+ server",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "updateOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": {
|
||||
"matchedCount": 1,
|
||||
"modifiedCount": 1,
|
||||
"upsertedCount": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"update": "coll0",
|
||||
"updates": [
|
||||
{
|
||||
"q": {
|
||||
"_id": 1
|
||||
},
|
||||
"u": [
|
||||
{
|
||||
"$set": {
|
||||
"foo": {
|
||||
"$setField": {
|
||||
"field": {
|
||||
"$literal": "a.b"
|
||||
},
|
||||
"value": 1,
|
||||
"input": "$foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"multi": {
|
||||
"$$unsetOrMatches": false
|
||||
},
|
||||
"upsert": {
|
||||
"$$unsetOrMatches": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"foo": {
|
||||
"a.b": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"description": "updateOne-validation",
|
||||
"schemaVersion": "1.1",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
@ -14,21 +14,21 @@
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-v2"
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "crud-v2"
|
||||
"collectionName": "coll0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "crud-v2",
|
||||
"databaseName": "crud-v2",
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
@ -42,8 +42,8 @@
|
||||
"description": "UpdateOne requires atomic modifiers",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection0",
|
||||
"name": "updateOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
@ -53,7 +53,7 @@
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"isError": true
|
||||
"isClientError": true
|
||||
}
|
||||
}
|
||||
],
|
||||
@ -65,8 +65,8 @@
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "crud-v2",
|
||||
"databaseName": "crud-v2",
|
||||
"collectionName": "coll0",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
|
||||
@ -892,13 +892,6 @@ class TestCollection(IntegrationTest):
|
||||
# This will pass with OP_UPDATE or the update command.
|
||||
self.db.test.replace_one({"bar": "x"}, {"bar": "x" * (max_size - 32)})
|
||||
|
||||
def test_bad_dbref(self):
|
||||
# Incomplete DBRefs.
|
||||
ref_only = {'ref': {'$ref': 'collection'}}
|
||||
id_only = {'ref': {'$id': ObjectId()}}
|
||||
self.assertRaises(InvalidDocument, self.db.test.insert_one, ref_only)
|
||||
self.assertRaises(InvalidDocument, self.db.test.insert_one, id_only)
|
||||
|
||||
@client_context.require_version_min(3, 1, 9, -1)
|
||||
def test_insert_bypass_document_validation(self):
|
||||
db = self.db
|
||||
@ -1215,34 +1208,6 @@ class TestCollection(IntegrationTest):
|
||||
self.assertEqual(x["hello"], "world")
|
||||
self.assertTrue("_id" in x)
|
||||
|
||||
def test_invalid_key_names(self):
|
||||
db = self.db
|
||||
db.test.drop()
|
||||
|
||||
db.test.insert_one({"hello": "world"})
|
||||
db.test.insert_one({"hello": {"hello": "world"}})
|
||||
|
||||
self.assertRaises(InvalidDocument, db.test.insert_one,
|
||||
{"$hello": "world"})
|
||||
self.assertRaises(InvalidDocument, db.test.insert_one,
|
||||
{"hello": {"$hello": "world"}})
|
||||
|
||||
db.test.insert_one({"he$llo": "world"})
|
||||
db.test.insert_one({"hello": {"hello$": "world"}})
|
||||
|
||||
self.assertRaises(InvalidDocument, db.test.insert_one,
|
||||
{".hello": "world"})
|
||||
self.assertRaises(InvalidDocument, db.test.insert_one,
|
||||
{"hello": {".hello": "world"}})
|
||||
self.assertRaises(InvalidDocument, db.test.insert_one,
|
||||
{"hello.": "world"})
|
||||
self.assertRaises(InvalidDocument, db.test.insert_one,
|
||||
{"hello": {"hello.": "world"}})
|
||||
self.assertRaises(InvalidDocument, db.test.insert_one,
|
||||
{"hel.lo": "world"})
|
||||
self.assertRaises(InvalidDocument, db.test.insert_one,
|
||||
{"hello": {"hel.lo": "world"}})
|
||||
|
||||
def test_unique_index(self):
|
||||
db = self.db
|
||||
db.drop_collection("test")
|
||||
|
||||
@ -131,15 +131,6 @@ class TestLegacyBulk(BulkTestBase):
|
||||
|
||||
self.assertEqual(2, self.coll.count())
|
||||
|
||||
def test_insert_check_keys(self):
|
||||
bulk = self.coll.initialize_ordered_bulk_op()
|
||||
bulk.insert({'$dollar': 1})
|
||||
self.assertRaises(InvalidDocument, bulk.execute)
|
||||
|
||||
bulk = self.coll.initialize_ordered_bulk_op()
|
||||
bulk.insert({'a.b': 1})
|
||||
self.assertRaises(InvalidDocument, bulk.execute)
|
||||
|
||||
def test_update(self):
|
||||
|
||||
expected = {
|
||||
|
||||
@ -61,14 +61,15 @@
|
||||
"object": "session0"
|
||||
},
|
||||
{
|
||||
"name": "insertOne",
|
||||
"name": "updateOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"session": "session0",
|
||||
"document": {
|
||||
"_id": {
|
||||
".": "."
|
||||
}
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": {
|
||||
"x": 1
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
|
||||
@ -607,9 +607,11 @@ def coerce_result(opname, result):
|
||||
if opname == 'bulkWrite':
|
||||
return parse_bulk_write_result(result)
|
||||
if opname == 'insertOne':
|
||||
return {'insertedId': result.inserted_id}
|
||||
return {'insertedId': result.inserted_id, 'insertedCount': 1}
|
||||
if opname == 'insertMany':
|
||||
return {idx: _id for idx, _id in enumerate(result.inserted_ids)}
|
||||
res = {idx: _id for idx, _id in enumerate(result.inserted_ids)}
|
||||
res['insertedCount'] = len(result.inserted_ids)
|
||||
return res
|
||||
if opname in ('deleteOne', 'deleteMany'):
|
||||
return {'deletedCount': result.deleted_count}
|
||||
if opname in ('updateOne', 'updateMany', 'replaceOne'):
|
||||
@ -698,6 +700,8 @@ class UnifiedSpecTestMixinV1(IntegrationTest):
|
||||
if 'Dirty explicit session is discarded' in spec['description']:
|
||||
raise unittest.SkipTest(
|
||||
"MMAPv1 does not support retryWrites=True")
|
||||
elif 'Client side error in command starting transaction' in spec['description']:
|
||||
raise unittest.SkipTest("Implement PYTHON-1894")
|
||||
|
||||
def process_error(self, exception, spec):
|
||||
is_error = spec.get('isError')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user