bson/testdata/crud/unified/aggregate-let.json
2025-03-17 20:58:26 +01:00

377 lines
8.4 KiB
JSON

{
"description": "aggregate-let",
"schemaVersion": "1.4",
"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"
}
}
],
"initialData": [
{
"collectionName": "coll0",
"databaseName": "crud-tests",
"documents": [
{
"_id": 1
}
]
},
{
"collectionName": "coll1",
"databaseName": "crud-tests",
"documents": []
}
],
"tests": [
{
"description": "Aggregate with let option",
"runOnRequirements": [
{
"minServerVersion": "5.0"
}
],
"operations": [
{
"name": "aggregate",
"object": "collection0",
"arguments": {
"pipeline": [
{
"$match": {
"$expr": {
"$eq": [
"$_id",
"$$id"
]
}
}
},
{
"$project": {
"_id": 0,
"x": "$$x",
"y": "$$y",
"rand": "$$rand"
}
}
],
"let": {
"id": 1,
"x": "foo",
"y": {
"$literal": "$bar"
},
"rand": {
"$rand": {}
}
}
},
"expectResult": [
{
"x": "foo",
"y": "$bar",
"rand": {
"$$type": "double"
}
}
]
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"aggregate": "coll0",
"pipeline": [
{
"$match": {
"$expr": {
"$eq": [
"$_id",
"$$id"
]
}
}
},
{
"$project": {
"_id": 0,
"x": "$$x",
"y": "$$y",
"rand": "$$rand"
}
}
],
"let": {
"id": 1,
"x": "foo",
"y": {
"$literal": "$bar"
},
"rand": {
"$rand": {}
}
}
}
}
}
]
}
]
},
{
"description": "Aggregate with let option unsupported (server-side error)",
"runOnRequirements": [
{
"minServerVersion": "2.6.0",
"maxServerVersion": "4.4.99"
}
],
"operations": [
{
"name": "aggregate",
"object": "collection0",
"arguments": {
"pipeline": [
{
"$match": {
"_id": 1
}
}
],
"let": {
"x": "foo"
}
},
"expectError": {
"errorContains": "unrecognized field 'let'",
"isClientError": false
}
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"aggregate": "coll0",
"pipeline": [
{
"$match": {
"_id": 1
}
}
],
"let": {
"x": "foo"
}
}
}
}
]
}
]
},
{
"description": "Aggregate to collection with let option",
"runOnRequirements": [
{
"minServerVersion": "5.0",
"serverless": "forbid"
}
],
"operations": [
{
"name": "aggregate",
"object": "collection0",
"arguments": {
"pipeline": [
{
"$match": {
"$expr": {
"$eq": [
"$_id",
"$$id"
]
}
}
},
{
"$project": {
"_id": 1
}
},
{
"$out": "coll1"
}
],
"let": {
"id": 1
}
}
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"aggregate": "coll0",
"pipeline": [
{
"$match": {
"$expr": {
"$eq": [
"$_id",
"$$id"
]
}
}
},
{
"$project": {
"_id": 1
}
},
{
"$out": "coll1"
}
],
"let": {
"id": 1
}
}
}
}
]
}
],
"outcome": [
{
"collectionName": "coll1",
"databaseName": "crud-tests",
"documents": [
{
"_id": 1
}
]
}
]
},
{
"description": "Aggregate to collection with let option unsupported (server-side error)",
"runOnRequirements": [
{
"minServerVersion": "2.6.0",
"maxServerVersion": "4.4.99"
}
],
"operations": [
{
"name": "aggregate",
"object": "collection0",
"arguments": {
"pipeline": [
{
"$match": {
"$expr": {
"$eq": [
"$_id",
"$$id"
]
}
}
},
{
"$project": {
"_id": 1
}
},
{
"$out": "coll1"
}
],
"let": {
"id": 1
}
},
"expectError": {
"errorContains": "unrecognized field 'let'",
"isClientError": false
}
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"aggregate": "coll0",
"pipeline": [
{
"$match": {
"$expr": {
"$eq": [
"$_id",
"$$id"
]
}
}
},
{
"$project": {
"_id": 1
}
},
{
"$out": "coll1"
}
],
"let": {
"id": 1
}
}
}
}
]
}
]
}
]
}