Commit 11a843eb authored by Katherine Walker's avatar Katherine Walker

PHPLIB-295 Sync arrayFilters crud tests

Also drop support for Mongo 2.4 (PHPLIB-282)
parent 762b6e90
...@@ -35,4 +35,4 @@ ...@@ -35,4 +35,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -65,6 +65,57 @@ ...@@ -65,6 +65,57 @@
] ]
} }
} }
},
{
"description": "Aggregate with $out and batch size of 0",
"operation": {
"name": "aggregate",
"arguments": {
"pipeline": [
{
"$sort": {
"x": 1
}
},
{
"$match": {
"_id": {
"$gt": 1
}
}
},
{
"$out": "other_test_collection"
}
],
"batchSize": 0
}
},
"outcome": {
"result": [
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
],
"collection": {
"name": "other_test_collection",
"data": [
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
]
}
}
} }
] ]
} }
\ No newline at end of file
...@@ -50,4 +50,4 @@ ...@@ -50,4 +50,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -26,4 +26,4 @@ ...@@ -26,4 +26,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -57,4 +57,4 @@ ...@@ -57,4 +57,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -30,4 +30,4 @@ ...@@ -30,4 +30,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -52,4 +52,4 @@ ...@@ -52,4 +52,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -31,4 +31,4 @@ ...@@ -31,4 +31,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -102,4 +102,4 @@ ...@@ -102,4 +102,4 @@
} }
} }
] ]
} }
\ No newline at end of file
{
"data": [
{
"_id": 1,
"y": [
{
"b": 3
},
{
"b": 1
}
]
},
{
"_id": 2,
"y": [
{
"b": 0
},
{
"b": 1
}
]
}
],
"minServerVersion": "3.5.6",
"tests": [
{
"description": "BulkWrite with arrayFilters",
"operation": {
"arguments": {
"options": {
"ordered": true
},
"requests": [
{
"arguments": {
"arrayFilters": [
{
"i.b": 3
}
],
"filter": {},
"update": {
"$set": {
"y.$[i].b": 2
}
}
},
"name": "updateOne"
},
{
"arguments": {
"arrayFilters": [
{
"i.b": 1
}
],
"filter": {},
"update": {
"$set": {
"y.$[i].b": 2
}
}
},
"name": "updateMany"
}
]
},
"name": "bulkWrite"
},
"outcome": {
"collection": {
"data": [
{
"_id": 1,
"y": [
{
"b": 2
},
{
"b": 2
}
]
},
{
"_id": 2,
"y": [
{
"b": 0
},
{
"b": 2
}
]
}
]
},
"result": {
"deletedCount": 0,
"insertedIds": {},
"matchedCount": 3,
"modifiedCount": 3,
"upsertedCount": 0,
"upsertedIds": {}
}
}
}
]
}
\ No newline at end of file
...@@ -44,4 +44,4 @@ ...@@ -44,4 +44,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -73,4 +73,4 @@ ...@@ -73,4 +73,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -48,4 +48,4 @@ ...@@ -48,4 +48,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -93,4 +93,4 @@ ...@@ -93,4 +93,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -56,4 +56,4 @@ ...@@ -56,4 +56,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -124,4 +124,4 @@ ...@@ -124,4 +124,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -55,4 +55,4 @@ ...@@ -55,4 +55,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -198,4 +198,4 @@ ...@@ -198,4 +198,4 @@
} }
} }
] ]
} }
\ No newline at end of file
{
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
],
"maxServerVersion": "2.4.99",
"tests": [
{
"description": "FindOneAndReplace when no documents match without id specified with upsert returning the document before modification",
"operation": {
"name": "findOneAndReplace",
"arguments": {
"filter": {
"_id": 4
},
"replacement": {
"x": 44
},
"projection": {
"x": 1,
"_id": 0
},
"upsert": true
}
},
"outcome": {
"result": null
}
},
{
"description": "FindOneAndReplace when no documents match without id specified with upsert returning the document after modification",
"operation": {
"name": "findOneAndReplace",
"arguments": {
"filter": {
"_id": 4
},
"replacement": {
"x": 44
},
"projection": {
"x": 1,
"_id": 0
},
"returnDocument": "After",
"sort": {
"x": 1
},
"upsert": true
}
},
"outcome": {
"result": {
"x": 44
}
}
},
{
"description": "FindOneAndReplace when no documents match with id specified with upsert returning the document before modification",
"operation": {
"name": "findOneAndReplace",
"arguments": {
"filter": {
"_id": 4
},
"replacement": {
"_id": 4,
"x": 44
},
"projection": {
"x": 1,
"_id": 0
},
"upsert": true
}
},
"outcome": {
"result": null,
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
},
{
"_id": 4,
"x": 44
}
]
}
}
},
{
"description": "FindOneAndReplace when no documents match with id specified with upsert returning the document after modification",
"operation": {
"name": "findOneAndReplace",
"arguments": {
"filter": {
"_id": 4
},
"replacement": {
"_id": 4,
"x": 44
},
"projection": {
"x": 1,
"_id": 0
},
"returnDocument": "After",
"sort": {
"x": 1
},
"upsert": true
}
},
"outcome": {
"result": {
"x": 44
},
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
},
{
"_id": 4,
"x": 44
}
]
}
}
}
]
}
\ No newline at end of file
...@@ -270,4 +270,4 @@ ...@@ -270,4 +270,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -2,162 +2,202 @@ ...@@ -2,162 +2,202 @@
"data": [ "data": [
{ {
"_id": 1, "_id": 1,
"x": 11 "y": [
{
"b": 3
},
{
"b": 1
}
]
}, },
{ {
"_id": 2, "_id": 2,
"x": 22 "y": [
}, {
{ "b": 0
"_id": 3, },
"x": 33 {
"b": 1
}
]
} }
], ],
"maxServerVersion": "2.4.99", "minServerVersion": "3.5.6",
"tests": [ "tests": [
{ {
"description": "UpdateOne when many documents match", "description": "FindOneAndUpdate when no document matches arrayFilters",
"operation": { "operation": {
"name": "updateOne", "name": "findOneAndUpdate",
"arguments": { "arguments": {
"filter": { "filter": {},
"_id": {
"$gt": 1
}
},
"update": { "update": {
"$inc": { "$set": {
"x": 1 "y.$[i].b": 2
} }
}
}
},
"outcome": {
"result": {
"matchedCount": 1,
"upsertedCount": 0
}
}
},
{
"description": "UpdateOne when one document matches",
"operation": {
"name": "updateOne",
"arguments": {
"filter": {
"_id": 1
}, },
"update": { "arrayFilters": [
"$inc": { {
"x": 1 "i.b": 4
} }
} ]
} }
}, },
"outcome": { "outcome": {
"result": { "result": {
"matchedCount": 1, "_id": 1,
"upsertedCount": 0 "y": [
{
"b": 3
},
{
"b": 1
}
]
}, },
"collection": { "collection": {
"data": [ "data": [
{ {
"_id": 1, "_id": 1,
"x": 12 "y": [
{
"b": 3
},
{
"b": 1
}
]
}, },
{ {
"_id": 2, "_id": 2,
"x": 22 "y": [
}, {
{ "b": 0
"_id": 3, },
"x": 33 {
"b": 1
}
]
} }
] ]
} }
} }
}, },
{ {
"description": "UpdateOne when no documents match", "description": "FindOneAndUpdate when one document matches arrayFilters",
"operation": { "operation": {
"name": "updateOne", "name": "findOneAndUpdate",
"arguments": { "arguments": {
"filter": { "filter": {},
"_id": 4
},
"update": { "update": {
"$inc": { "$set": {
"x": 1 "y.$[i].b": 2
} }
} },
"arrayFilters": [
{
"i.b": 3
}
]
} }
}, },
"outcome": { "outcome": {
"result": { "result": {
"matchedCount": 0, "_id": 1,
"upsertedCount": 0 "y": [
{
"b": 3
},
{
"b": 1
}
]
}, },
"collection": { "collection": {
"data": [ "data": [
{ {
"_id": 1, "_id": 1,
"x": 11 "y": [
{
"b": 2
},
{
"b": 1
}
]
}, },
{ {
"_id": 2, "_id": 2,
"x": 22 "y": [
}, {
{ "b": 0
"_id": 3, },
"x": 33 {
"b": 1
}
]
} }
] ]
} }
} }
}, },
{ {
"description": "UpdateOne with upsert when no documents match", "description": "FindOneAndUpdate when multiple documents match arrayFilters",
"operation": { "operation": {
"name": "updateOne", "name": "findOneAndUpdate",
"arguments": { "arguments": {
"filter": { "filter": {},
"_id": 4
},
"update": { "update": {
"$inc": { "$set": {
"x": 1 "y.$[i].b": 2
} }
}, },
"upsert": true "arrayFilters": [
{
"i.b": 1
}
]
} }
}, },
"outcome": { "outcome": {
"result": { "result": {
"matchedCount": 0, "_id": 1,
"upsertedCount": 1, "y": [
"upsertedId": 4 {
"b": 3
},
{
"b": 1
}
]
}, },
"collection": { "collection": {
"data": [ "data": [
{ {
"_id": 1, "_id": 1,
"x": 11 "y": [
{
"b": 3
},
{
"b": 2
}
]
}, },
{ {
"_id": 2, "_id": 2,
"x": 22 "y": [
}, {
{ "b": 0
"_id": 3, },
"x": 33 {
}, "b": 1
{ }
"_id": 4, ]
"x": 1
} }
] ]
} }
} }
} }
] ]
} }
\ No newline at end of file
...@@ -64,4 +64,4 @@ ...@@ -64,4 +64,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -376,4 +376,4 @@ ...@@ -376,4 +376,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -49,4 +49,4 @@ ...@@ -49,4 +49,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -36,4 +36,4 @@ ...@@ -36,4 +36,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -50,4 +50,4 @@ ...@@ -50,4 +50,4 @@
} }
} }
] ]
} }
\ No newline at end of file
{
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
],
"maxServerVersion": "2.4.99",
"tests": [
{
"description": "ReplaceOne when many documents match",
"operation": {
"name": "replaceOne",
"arguments": {
"filter": {
"_id": {
"$gt": 1
}
},
"replacement": {
"x": 111
}
}
},
"outcome": {
"result": {
"matchedCount": 1,
"upsertedCount": 0
}
}
},
{
"description": "ReplaceOne when one document matches",
"operation": {
"name": "replaceOne",
"arguments": {
"filter": {
"_id": 1
},
"replacement": {
"_id": 1,
"x": 111
}
}
},
"outcome": {
"result": {
"matchedCount": 1,
"upsertedCount": 0
},
"collection": {
"data": [
{
"_id": 1,
"x": 111
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
]
}
}
},
{
"description": "ReplaceOne when no documents match",
"operation": {
"name": "replaceOne",
"arguments": {
"filter": {
"_id": 4
},
"replacement": {
"_id": 4,
"x": 1
}
}
},
"outcome": {
"result": {
"matchedCount": 0,
"upsertedCount": 0
},
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
]
}
}
},
{
"description": "ReplaceOne with upsert when no documents match without an id specified",
"operation": {
"name": "replaceOne",
"arguments": {
"filter": {
"_id": 4
},
"replacement": {
"x": 1
},
"upsert": true
}
},
"outcome": {
"result": {
"matchedCount": 0,
"upsertedCount": 1
}
}
},
{
"description": "ReplaceOne with upsert when no documents match with an id specified",
"operation": {
"name": "replaceOne",
"arguments": {
"filter": {
"_id": 4
},
"replacement": {
"_id": 4,
"x": 1
},
"upsert": true
}
},
"outcome": {
"result": {
"matchedCount": 0,
"upsertedCount": 1,
"upsertedId": 4
},
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
},
{
"_id": 4,
"x": 1
}
]
}
}
}
]
}
\ No newline at end of file
{
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
],
"minServerVersion": "2.6",
"tests": [
{
"description": "ReplaceOne with upsert when no documents match without an id specified",
"operation": {
"arguments": {
"filter": {
"_id": 4
},
"replacement": {
"x": 1
},
"upsert": true
},
"name": "replaceOne"
},
"outcome": {
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
},
{
"_id": 4,
"x": 1
}
]
},
"result": {
"matchedCount": 0,
"modifiedCount": 0,
"upsertedId": 4
}
}
},
{
"description": "ReplaceOne with upsert when no documents match with an id specified",
"operation": {
"arguments": {
"filter": {
"_id": 4
},
"replacement": {
"_id": 4,
"x": 1
},
"upsert": true
},
"name": "replaceOne"
},
"outcome": {
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
},
{
"_id": 4,
"x": 1
}
]
},
"result": {
"matchedCount": 0,
"modifiedCount": 0,
"upsertedId": 4
}
}
}
]
}
...@@ -202,4 +202,4 @@ ...@@ -202,4 +202,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -2,178 +2,181 @@ ...@@ -2,178 +2,181 @@
"data": [ "data": [
{ {
"_id": 1, "_id": 1,
"x": 11 "y": [
{
"b": 3
},
{
"b": 1
}
]
}, },
{ {
"_id": 2, "_id": 2,
"x": 22 "y": [
}, {
{ "b": 0
"_id": 3, },
"x": 33 {
"b": 1
}
]
} }
], ],
"maxServerVersion": "2.4.99", "minServerVersion": "3.5.6",
"tests": [ "tests": [
{ {
"description": "UpdateMany when many documents match", "description": "UpdateMany when no documents match arrayFilters",
"operation": { "operation": {
"name": "updateMany", "name": "updateMany",
"arguments": { "arguments": {
"filter": { "filter": {},
"_id": { "update": {
"$gt": 1 "$set": {
"y.$[i].b": 2
} }
}, },
"update": { "arrayFilters": [
"$inc": { {
"x": 1 "i.b": 4
} }
} ]
} }
}, },
"outcome": { "outcome": {
"result": { "result": {
"matchedCount": 2, "matchedCount": 2,
"upsertedCount": 0 "modifiedCount": 0
}, },
"collection": { "collection": {
"data": [ "data": [
{ {
"_id": 1, "_id": 1,
"x": 11 "y": [
{
"b": 3
},
{
"b": 1
}
]
}, },
{ {
"_id": 2, "_id": 2,
"x": 23 "y": [
}, {
{ "b": 0
"_id": 3, },
"x": 34 {
"b": 1
}
]
} }
] ]
} }
} }
}, },
{ {
"description": "UpdateMany when one document matches", "description": "UpdateMany when one document matches arrayFilters",
"operation": { "operation": {
"name": "updateMany", "name": "updateMany",
"arguments": { "arguments": {
"filter": { "filter": {},
"_id": 1
},
"update": { "update": {
"$inc": { "$set": {
"x": 1 "y.$[i].b": 2
} }
} },
} "arrayFilters": [
},
"outcome": {
"result": {
"matchedCount": 1,
"upsertedCount": 0
},
"collection": {
"data": [
{
"_id": 1,
"x": 12
},
{
"_id": 2,
"x": 22
},
{ {
"_id": 3, "i.b": 3
"x": 33
} }
] ]
} }
}
},
{
"description": "UpdateMany when no documents match",
"operation": {
"name": "updateMany",
"arguments": {
"filter": {
"_id": 4
},
"update": {
"$inc": {
"x": 1
}
}
}
}, },
"outcome": { "outcome": {
"result": { "result": {
"matchedCount": 0, "matchedCount": 2,
"upsertedCount": 0 "modifiedCount": 1
}, },
"collection": { "collection": {
"data": [ "data": [
{ {
"_id": 1, "_id": 1,
"x": 11 "y": [
{
"b": 2
},
{
"b": 1
}
]
}, },
{ {
"_id": 2, "_id": 2,
"x": 22 "y": [
}, {
{ "b": 0
"_id": 3, },
"x": 33 {
"b": 1
}
]
} }
] ]
} }
} }
}, },
{ {
"description": "UpdateMany with upsert when no documents match", "description": "UpdateMany when multiple documents match arrayFilters",
"operation": { "operation": {
"name": "updateMany", "name": "updateMany",
"arguments": { "arguments": {
"filter": { "filter": {},
"_id": 4
},
"update": { "update": {
"$inc": { "$set": {
"x": 1 "y.$[i].b": 2
} }
}, },
"upsert": true "arrayFilters": [
{
"i.b": 1
}
]
} }
}, },
"outcome": { "outcome": {
"result": { "result": {
"matchedCount": 0, "matchedCount": 2,
"upsertedCount": 1, "modifiedCount": 2
"upsertedId": 4
}, },
"collection": { "collection": {
"data": [ "data": [
{ {
"_id": 1, "_id": 1,
"x": 11 "y": [
{
"b": 3
},
{
"b": 2
}
]
}, },
{ {
"_id": 2, "_id": 2,
"x": 22 "y": [
}, {
{ "b": 0
"_id": 3, },
"x": 33 {
}, "b": 2
{ }
"_id": 4, ]
"x": 1
} }
] ]
} }
} }
} }
] ]
} }
\ No newline at end of file
...@@ -59,4 +59,4 @@ ...@@ -59,4 +59,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -180,4 +180,4 @@ ...@@ -180,4 +180,4 @@
} }
} }
] ]
} }
\ No newline at end of file
{
"data": [
{
"_id": 1,
"y": [
{
"b": 3
},
{
"b": 1
}
]
},
{
"_id": 2,
"y": [
{
"b": 0
},
{
"b": 1
}
]
},
{
"_id": 3,
"y": [
{
"b": 5,
"c": [
{
"d": 2
},
{
"d": 1
}
]
}
]
}
],
"minServerVersion": "3.5.6",
"tests": [
{
"description": "UpdateOne when no document matches arrayFilters",
"operation": {
"name": "updateOne",
"arguments": {
"filter": {},
"update": {
"$set": {
"y.$[i].b": 2
}
},
"arrayFilters": [
{
"i.b": 4
}
]
}
},
"outcome": {
"result": {
"matchedCount": 1,
"modifiedCount": 0
},
"collection": {
"data": [
{
"_id": 1,
"y": [
{
"b": 3
},
{
"b": 1
}
]
},
{
"_id": 2,
"y": [
{
"b": 0
},
{
"b": 1
}
]
},
{
"_id": 3,
"y": [
{
"b": 5,
"c": [
{
"d": 2
},
{
"d": 1
}
]
}
]
}
]
}
}
},
{
"description": "UpdateOne when one document matches arrayFilters",
"operation": {
"name": "updateOne",
"arguments": {
"filter": {},
"update": {
"$set": {
"y.$[i].b": 2
}
},
"arrayFilters": [
{
"i.b": 3
}
]
}
},
"outcome": {
"result": {
"matchedCount": 1,
"modifiedCount": 1
},
"collection": {
"data": [
{
"_id": 1,
"y": [
{
"b": 2
},
{
"b": 1
}
]
},
{
"_id": 2,
"y": [
{
"b": 0
},
{
"b": 1
}
]
},
{
"_id": 3,
"y": [
{
"b": 5,
"c": [
{
"d": 2
},
{
"d": 1
}
]
}
]
}
]
}
}
},
{
"description": "UpdateOne when multiple documents match arrayFilters",
"operation": {
"name": "updateOne",
"arguments": {
"filter": {},
"update": {
"$set": {
"y.$[i].b": 2
}
},
"arrayFilters": [
{
"i.b": 1
}
]
}
},
"outcome": {
"result": {
"matchedCount": 1,
"modifiedCount": 1
},
"collection": {
"data": [
{
"_id": 1,
"y": [
{
"b": 3
},
{
"b": 2
}
]
},
{
"_id": 2,
"y": [
{
"b": 0
},
{
"b": 1
}
]
},
{
"_id": 3,
"y": [
{
"b": 5,
"c": [
{
"d": 2
},
{
"d": 1
}
]
}
]
}
]
}
}
},
{
"description": "UpdateOne when no documents match multiple arrayFilters",
"operation": {
"name": "updateOne",
"arguments": {
"filter": {
"_id": 3
},
"update": {
"$set": {
"y.$[i].c.$[j].d": 0
}
},
"arrayFilters": [
{
"i.b": 5
},
{
"j.d": 3
}
]
}
},
"outcome": {
"result": {
"matchedCount": 1,
"modifiedCount": 0
},
"collection": {
"data": [
{
"_id": 1,
"y": [
{
"b": 3
},
{
"b": 1
}
]
},
{
"_id": 2,
"y": [
{
"b": 0
},
{
"b": 1
}
]
},
{
"_id": 3,
"y": [
{
"b": 5,
"c": [
{
"d": 2
},
{
"d": 1
}
]
}
]
}
]
}
}
},
{
"description": "UpdateOne when one document matches multiple arrayFilters",
"operation": {
"name": "updateOne",
"arguments": {
"filter": {
"_id": 3
},
"update": {
"$set": {
"y.$[i].c.$[j].d": 0
}
},
"arrayFilters": [
{
"i.b": 5
},
{
"j.d": 1
}
]
}
},
"outcome": {
"result": {
"matchedCount": 1,
"modifiedCount": 1
},
"collection": {
"data": [
{
"_id": 1,
"y": [
{
"b": 3
},
{
"b": 1
}
]
},
{
"_id": 2,
"y": [
{
"b": 0
},
{
"b": 1
}
]
},
{
"_id": 3,
"y": [
{
"b": 5,
"c": [
{
"d": 2
},
{
"d": 0
}
]
}
]
}
]
}
}
}
]
}
...@@ -51,4 +51,4 @@ ...@@ -51,4 +51,4 @@
} }
} }
] ]
} }
\ No newline at end of file
...@@ -164,4 +164,4 @@ ...@@ -164,4 +164,4 @@
} }
} }
] ]
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment