bson/testdata/crud/unified/bulkWrite-updateMany-dots_and_dollars.json
2025-03-17 20:58:26 +01:00

453 lines
11 KiB
JSON

{
"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
}
}
]
}
]
}
]
}