mongo-python-driver/test/unified-test-format/valid-pass/operator-matchAsDocument.json
Shane Harvey 0733c4da44
PYTHON-4925 Fix test bugs in $$matchAsDocument and $$matchAsRoot (#1988)
Fixes a bug where the driverConnectionId field was missing from "server heartbeat failed" log messages.
Avoids sending "upsert": False since various client.bulkWrite spec tests assume this field is only sent when it's True.
2024-11-05 12:19:51 -08:00

125 lines
2.5 KiB
JSON

{
"description": "operator-matchAsDocument",
"schemaVersion": "1.13",
"createEntities": [
{
"client": {
"id": "client0"
}
},
{
"database": {
"id": "database0",
"client": "client0",
"databaseName": "test"
}
},
{
"collection": {
"id": "collection0",
"database": "database0",
"collectionName": "coll0"
}
}
],
"initialData": [
{
"collectionName": "coll0",
"databaseName": "test",
"documents": [
{
"_id": 1,
"json": "{ \"x\": 1, \"y\": 2.0 }"
},
{
"_id": 2,
"json": "{ \"x\": { \"$oid\": \"57e193d7a9cc81b4027498b5\" } }"
}
]
}
],
"tests": [
{
"description": "matchAsDocument performs flexible numeric comparisons",
"operations": [
{
"name": "find",
"object": "collection0",
"arguments": {
"filter": {
"_id": 1
},
"limit": 1
},
"expectResult": [
{
"_id": 1,
"json": {
"$$matchAsDocument": {
"x": 1,
"y": 2
}
}
}
]
}
]
},
{
"description": "matchAsDocument evaluates special operators",
"operations": [
{
"name": "find",
"object": "collection0",
"arguments": {
"filter": {
"_id": 1
},
"limit": 1
},
"expectResult": [
{
"_id": 1,
"json": {
"$$matchAsDocument": {
"x": 1,
"y": {
"$$exists": true
}
}
}
}
]
}
]
},
{
"description": "matchAsDocument decodes Extended JSON",
"operations": [
{
"name": "find",
"object": "collection0",
"arguments": {
"filter": {
"_id": 2
},
"limit": 1
},
"expectResult": [
{
"_id": 2,
"json": {
"$$matchAsDocument": {
"x": {
"$$type": "objectId"
}
}
}
}
]
}
]
}
]
}