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
......@@ -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
}
]
}
}
}
]
}
{
"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
{
"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
......@@ -2,158 +2,198 @@
"data": [
{
"_id": 1,
"x": 11
"y": [
{
"b": 3
},
{
"b": 1
}
]
},
{
"_id": 2,
"x": 22
"y": [
{
"b": 0
},
{
"_id": 3,
"x": 33
"b": 1
}
]
}
],
"maxServerVersion": "2.4.99",
"minServerVersion": "3.5.6",
"tests": [
{
"description": "UpdateOne when many documents match",
"description": "FindOneAndUpdate when no document matches arrayFilters",
"operation": {
"name": "updateOne",
"name": "findOneAndUpdate",
"arguments": {
"filter": {
"_id": {
"$gt": 1
}
},
"filter": {},
"update": {
"$inc": {
"x": 1
"$set": {
"y.$[i].b": 2
}
},
"arrayFilters": [
{
"i.b": 4
}
]
}
},
"outcome": {
"result": {
"matchedCount": 1,
"upsertedCount": 0
}
}
},
"_id": 1,
"y": [
{
"description": "UpdateOne when one document matches",
"operation": {
"name": "updateOne",
"arguments": {
"filter": {
"_id": 1
"b": 3
},
"update": {
"$inc": {
"x": 1
}
}
{
"b": 1
}
},
"outcome": {
"result": {
"matchedCount": 1,
"upsertedCount": 0
]
},
"collection": {
"data": [
{
"_id": 1,
"x": 12
"y": [
{
"b": 3
},
{
"b": 1
}
]
},
{
"_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": {
"name": "updateOne",
"name": "findOneAndUpdate",
"arguments": {
"filter": {
"_id": 4
},
"filter": {},
"update": {
"$inc": {
"x": 1
"$set": {
"y.$[i].b": 2
}
},
"arrayFilters": [
{
"i.b": 3
}
]
}
},
"outcome": {
"result": {
"matchedCount": 0,
"upsertedCount": 0
"_id": 1,
"y": [
{
"b": 3
},
{
"b": 1
}
]
},
"collection": {
"data": [
{
"_id": 1,
"x": 11
"y": [
{
"b": 2
},
{
"b": 1
}
]
},
{
"_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": {
"name": "updateOne",
"name": "findOneAndUpdate",
"arguments": {
"filter": {
"_id": 4
},
"filter": {},
"update": {
"$inc": {
"x": 1
"$set": {
"y.$[i].b": 2
}
},
"upsert": true
"arrayFilters": [
{
"i.b": 1
}
]
}
},
"outcome": {
"result": {
"matchedCount": 0,
"upsertedCount": 1,
"upsertedId": 4
"_id": 1,
"y": [
{
"b": 3
},
{
"b": 1
}
]
},
"collection": {
"data": [
{
"_id": 1,
"x": 11
"y": [
{
"b": 3
},
{
"_id": 2,
"x": 22
"b": 2
}
]
},
{
"_id": 3,
"x": 33
"_id": 2,
"y": [
{
"b": 0
},
{
"_id": 4,
"x": 1
"b": 1
}
]
}
]
}
......
{
"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
}
}
}
]
}
......@@ -2,174 +2,177 @@
"data": [
{
"_id": 1,
"x": 11
"y": [
{
"b": 3
},
{
"b": 1
}
]
},
{
"_id": 2,
"x": 22
"y": [
{
"b": 0
},
{
"_id": 3,
"x": 33
"b": 1
}
]
}
],
"maxServerVersion": "2.4.99",
"minServerVersion": "3.5.6",
"tests": [
{
"description": "UpdateMany when many documents match",
"description": "UpdateMany when no documents match arrayFilters",
"operation": {
"name": "updateMany",
"arguments": {
"filter": {
"_id": {
"$gt": 1
}
},
"filter": {},
"update": {
"$inc": {
"x": 1
"$set": {
"y.$[i].b": 2
}
},
"arrayFilters": [
{
"i.b": 4
}
]
}
},
"outcome": {
"result": {
"matchedCount": 2,
"upsertedCount": 0
"modifiedCount": 0
},
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
"y": [
{
"_id": 2,
"x": 23
"b": 3
},
{
"_id": 3,
"x": 34
"b": 1
}
]
}
}
},
{
"description": "UpdateMany when one document matches",
"operation": {
"name": "updateMany",
"arguments": {
"filter": {
"_id": 1
},
"update": {
"$inc": {
"x": 1
}
}
}
},
"outcome": {
"result": {
"matchedCount": 1,
"upsertedCount": 0
},
"collection": {
"data": [
{
"_id": 1,
"x": 12
},
{
"_id": 2,
"x": 22
"y": [
{
"b": 0
},
{
"_id": 3,
"x": 33
"b": 1
}
]
}
]
}
}
},
{
"description": "UpdateMany when no documents match",
"description": "UpdateMany when one document matches arrayFilters",
"operation": {
"name": "updateMany",
"arguments": {
"filter": {
"_id": 4
},
"filter": {},
"update": {
"$inc": {
"x": 1
"$set": {
"y.$[i].b": 2
}
},
"arrayFilters": [
{
"i.b": 3
}
]
}
},
"outcome": {
"result": {
"matchedCount": 0,
"upsertedCount": 0
"matchedCount": 2,
"modifiedCount": 1
},
"collection": {
"data": [
{
"_id": 1,
"x": 11
"y": [
{
"b": 2
},
{
"b": 1
}
]
},
{
"_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": {
"name": "updateMany",
"arguments": {
"filter": {
"_id": 4
},
"filter": {},
"update": {
"$inc": {
"x": 1
"$set": {
"y.$[i].b": 2
}
},
"upsert": true
"arrayFilters": [
{
"i.b": 1
}
]
}
},
"outcome": {
"result": {
"matchedCount": 0,
"upsertedCount": 1,
"upsertedId": 4
"matchedCount": 2,
"modifiedCount": 2
},
"collection": {
"data": [
{
"_id": 1,
"x": 11
"y": [
{
"b": 3
},
{
"_id": 2,
"x": 22
"b": 2
}
]
},
{
"_id": 3,
"x": 33
"_id": 2,
"y": [
{
"b": 0
},
{
"_id": 4,
"x": 1
"b": 2
}
]
}
]
}
......
{
"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
}
]
}
]
}
]
}
}
}
]
}
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