diff --git a/source/crud/tests/read/aggregate-collation.json b/source/crud/tests/read/aggregate-collation.json index 7857cb229a..903a5834e8 100644 --- a/source/crud/tests/read/aggregate-collation.json +++ b/source/crud/tests/read/aggregate-collation.json @@ -1,38 +1,38 @@ { - "data": [ - { - "_id": 1, - "x": "ping" - } - ], - "minServerVersion": "3.4", - "tests": [ - { - "description": "Aggregate with collation", - "operation": { - "arguments": { - "collation": { - "locale": "en_US", - "strength": 2 - }, - "pipeline": [ - { - "$match": { - "x": "PING" - } - } - ] - }, - "name": "aggregate" - }, - "outcome": { - "result": [ - { - "_id": 1, - "x": "ping" - } - ] + "data": [ + { + "_id": 1, + "x": "ping" + } + ], + "minServerVersion": "3.4", + "tests": [ + { + "description": "Aggregate with collation", + "operation": { + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$match": { + "x": "PING" + } } + ], + "collation": { + "locale": "en_US", + "strength": 2 + } } - ] -} + }, + "outcome": { + "result": [ + { + "_id": 1, + "x": "ping" + } + ] + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/read/aggregate-out.json b/source/crud/tests/read/aggregate-out.json index 51b5afcf5a..cbc8ca47ba 100644 --- a/source/crud/tests/read/aggregate-out.json +++ b/source/crud/tests/read/aggregate-out.json @@ -1,70 +1,70 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ], + "minServerVersion": "2.6", + "tests": [ + { + "description": "Aggregate with $out", + "operation": { + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$sort": { + "x": 1 + } + }, + { + "$match": { + "_id": { + "$gt": 1 + } + } + }, + { + "$out": "other_test_collection" + } + ], + "batchSize": 2 + } + }, + "outcome": { + "result": [ + { + "_id": 2, "x": 22 - }, - { - "_id": 3, + }, + { + "_id": 3, "x": 33 - } - ], - "minServerVersion": "2.6", - "tests": [ - { - "description": "Aggregate with $out", - "operation": { - "arguments": { - "batchSize": 2, - "pipeline": [ - { - "$sort": { - "x": 1 - } - }, - { - "$match": { - "_id": { - "$gt": 1 - } - } - }, - { - "$out": "other_test_collection" - } - ] - }, - "name": "aggregate" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ], - "name": "other_test_collection" - }, - "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 diff --git a/source/crud/tests/read/aggregate.json b/source/crud/tests/read/aggregate.json index b1733855ef..479fcb9b7e 100644 --- a/source/crud/tests/read/aggregate.json +++ b/source/crud/tests/read/aggregate.json @@ -1,53 +1,53 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ], - "tests": [ - { - "description": "Aggregate with multiple stages", - "operation": { - "arguments": { - "batchSize": 2, - "pipeline": [ - { - "$sort": { - "x": 1 - } - }, - { - "$match": { - "_id": { - "$gt": 1 - } - } - } - ] - }, - "name": "aggregate" - }, - "outcome": { - "result": [ - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ], + "tests": [ + { + "description": "Aggregate with multiple stages", + "operation": { + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$sort": { + "x": 1 + } + }, + { + "$match": { + "_id": { + "$gt": 1 + } + } } + ], + "batchSize": 2 } - ] -} + }, + "outcome": { + "result": [ + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/read/count-collation.json b/source/crud/tests/read/count-collation.json index 377d096be8..4621209428 100644 --- a/source/crud/tests/read/count-collation.json +++ b/source/crud/tests/read/count-collation.json @@ -1,29 +1,29 @@ { - "data": [ - { - "_id": 1, - "x": "PING" + "data": [ + { + "_id": 1, + "x": "PING" + } + ], + "minServerVersion": "3.4", + "tests": [ + { + "description": "Count with collation", + "operation": { + "name": "count", + "arguments": { + "filter": { + "x": "ping" + }, + "collation": { + "locale": "en_US", + "strength": 2 + } } - ], - "minServerVersion": "3.4", - "tests": [ - { - "description": "Count with collation", - "operation": { - "arguments": { - "collation": { - "locale": "en_US", - "strength": 2 - }, - "filter": { - "x": "ping" - } - }, - "name": "count" - }, - "outcome": { - "result": 1 - } - } - ] -} + }, + "outcome": { + "result": 1 + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/read/count.json b/source/crud/tests/read/count.json index 6e061414b0..85c17e11a2 100644 --- a/source/crud/tests/read/count.json +++ b/source/crud/tests/read/count.json @@ -1,60 +1,60 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ], + "tests": [ + { + "description": "Count without a filter", + "operation": { + "name": "count", + "arguments": { + "filter": {} } - ], - "tests": [ - { - "description": "Count without a filter", - "operation": { - "arguments": { - "filter": {} - }, - "name": "count" - }, - "outcome": { - "result": 3 - } - }, - { - "description": "Count with a filter", - "operation": { - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - } - }, - "name": "count" - }, - "outcome": { - "result": 2 - } - }, - { - "description": "Count with skip and limit", - "operation": { - "arguments": { - "filter": {}, - "limit": 3, - "skip": 1 - }, - "name": "count" - }, - "outcome": { - "result": 2 + }, + "outcome": { + "result": 3 + } + }, + { + "description": "Count with a filter", + "operation": { + "name": "count", + "arguments": { + "filter": { + "_id": { + "$gt": 1 } + } + } + }, + "outcome": { + "result": 2 + } + }, + { + "description": "Count with skip and limit", + "operation": { + "name": "count", + "arguments": { + "filter": {}, + "skip": 1, + "limit": 3 } - ] -} + }, + "outcome": { + "result": 2 + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/read/distinct-collation.json b/source/crud/tests/read/distinct-collation.json index 4b6d38cc60..4d688cc3db 100644 --- a/source/crud/tests/read/distinct-collation.json +++ b/source/crud/tests/read/distinct-collation.json @@ -1,33 +1,33 @@ { - "data": [ - { - "_id": 1, - "string": "PING" - }, - { - "_id": 2, - "string": "ping" + "data": [ + { + "_id": 1, + "string": "PING" + }, + { + "_id": 2, + "string": "ping" + } + ], + "minServerVersion": "3.4", + "tests": [ + { + "description": "Distinct with a collation", + "operation": { + "name": "distinct", + "arguments": { + "fieldName": "string", + "collation": { + "locale": "en_US", + "strength": 2 + } } - ], - "minServerVersion": "3.4", - "tests": [ - { - "description": "Distinct with a collation", - "operation": { - "arguments": { - "collation": { - "locale": "en_US", - "strength": 2 - }, - "fieldName": "string" - }, - "name": "distinct" - }, - "outcome": { - "result": [ - "PING" - ] - } - } - ] -} + }, + "outcome": { + "result": [ + "PING" + ] + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/read/distinct.json b/source/crud/tests/read/distinct.json index 941368a811..408d8a4805 100644 --- a/source/crud/tests/read/distinct.json +++ b/source/crud/tests/read/distinct.json @@ -1,55 +1,55 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ], + "tests": [ + { + "description": "Distinct without a filter", + "operation": { + "name": "distinct", + "arguments": { + "fieldName": "x", + "filter": {} } - ], - "tests": [ - { - "description": "Distinct without a filter", - "operation": { - "arguments": { - "fieldName": "x", - "filter": {} - }, - "name": "distinct" - }, - "outcome": { - "result": [ - 11, - 22, - 33 - ] - } - }, - { - "description": "Distinct with a filter", - "operation": { - "arguments": { - "fieldName": "x", - "filter": { - "_id": { - "$gt": 1 - } - } - }, - "name": "distinct" - }, - "outcome": { - "result": [ - 22, - 33 - ] + }, + "outcome": { + "result": [ + 11, + 22, + 33 + ] + } + }, + { + "description": "Distinct with a filter", + "operation": { + "name": "distinct", + "arguments": { + "fieldName": "x", + "filter": { + "_id": { + "$gt": 1 } + } } - ] -} + }, + "outcome": { + "result": [ + 22, + 33 + ] + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/read/find-collation.json b/source/crud/tests/read/find-collation.json index 94d72fc3d6..b2d268ae31 100644 --- a/source/crud/tests/read/find-collation.json +++ b/source/crud/tests/read/find-collation.json @@ -1,34 +1,34 @@ { - "data": [ - { - "_id": 1, - "x": "ping" - } - ], - "minServerVersion": "3.4", - "tests": [ - { - "description": "Find with a collation", - "operation": { - "arguments": { - "collation": { - "locale": "en_US", - "strength": 2 - }, - "filter": { - "x": "PING" - } - }, - "name": "find" - }, - "outcome": { - "result": [ - { - "_id": 1, - "x": "ping" - } - ] - } + "data": [ + { + "_id": 1, + "x": "ping" + } + ], + "minServerVersion": "3.4", + "tests": [ + { + "description": "Find with a collation", + "operation": { + "name": "find", + "arguments": { + "filter": { + "x": "PING" + }, + "collation": { + "locale": "en_US", + "strength": 2 + } } - ] -} + }, + "outcome": { + "result": [ + { + "_id": 1, + "x": "ping" + } + ] + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/read/find.json b/source/crud/tests/read/find.json index 2f20313715..d92081d551 100644 --- a/source/crud/tests/read/find.json +++ b/source/crud/tests/read/find.json @@ -1,105 +1,105 @@ { - "data": [ - { - "_id": 1, + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + }, + { + "_id": 4, + "x": 44 + }, + { + "_id": 5, + "x": 55 + } + ], + "tests": [ + { + "description": "Find with filter", + "operation": { + "name": "find", + "arguments": { + "filter": { + "_id": 1 + } + } + }, + "outcome": { + "result": [ + { + "_id": 1, + "x": 11 + } + ] + } + }, + { + "description": "Find with filter, sort, skip, and limit", + "operation": { + "name": "find", + "arguments": { + "filter": { + "_id": { + "$gt": 2 + } + }, + "sort": { + "_id": 1 + }, + "skip": 2, + "limit": 2 + } + }, + "outcome": { + "result": [ + { + "_id": 5, + "x": 55 + } + ] + } + }, + { + "description": "Find with limit, sort, and batchsize", + "operation": { + "name": "find", + "arguments": { + "filter": {}, + "sort": { + "_id": 1 + }, + "limit": 4, + "batchSize": 2 + } + }, + "outcome": { + "result": [ + { + "_id": 1, "x": 11 - }, - { - "_id": 2, + }, + { + "_id": 2, "x": 22 - }, - { - "_id": 3, + }, + { + "_id": 3, "x": 33 - }, - { - "_id": 4, + }, + { + "_id": 4, "x": 44 - }, - { - "_id": 5, - "x": 55 - } - ], - "tests": [ - { - "description": "Find with filter", - "operation": { - "arguments": { - "filter": { - "_id": 1 - } - }, - "name": "find" - }, - "outcome": { - "result": [ - { - "_id": 1, - "x": 11 - } - ] - } - }, - { - "description": "Find with filter, sort, skip, and limit", - "operation": { - "arguments": { - "filter": { - "_id": { - "$gt": 2 - } - }, - "limit": 2, - "skip": 2, - "sort": { - "_id": 1 - } - }, - "name": "find" - }, - "outcome": { - "result": [ - { - "_id": 5, - "x": 55 - } - ] - } - }, - { - "description": "Find with limit, sort, and batchsize", - "operation": { - "arguments": { - "batchSize": 2, - "filter": {}, - "limit": 4, - "sort": { - "_id": 1 - } - }, - "name": "find" - }, - "outcome": { - "result": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - }, - { - "_id": 4, - "x": 44 - } - ] - } - } - ] -} + } + ] + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/write/deleteMany-collation.json b/source/crud/tests/write/deleteMany-collation.json index d3a13e984f..593ad68560 100644 --- a/source/crud/tests/write/deleteMany-collation.json +++ b/source/crud/tests/write/deleteMany-collation.json @@ -1,47 +1,47 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": "ping" - }, - { - "_id": 3, - "x": "pINg" + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": "ping" + }, + { + "_id": 3, + "x": "pINg" + } + ], + "minServerVersion": "3.4", + "tests": [ + { + "description": "DeleteMany when many documents match with collation", + "operation": { + "name": "deleteMany", + "arguments": { + "filter": { + "x": "PING" + }, + "collation": { + "locale": "en_US", + "strength": 2 + } } - ], - "minServerVersion": "3.4", - "tests": [ - { - "description": "DeleteMany when many documents match with collation", - "operation": { - "arguments": { - "collation": { - "locale": "en_US", - "strength": 2 - }, - "filter": { - "x": "PING" - } - }, - "name": "deleteMany" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - } - ] - }, - "result": { - "deletedCount": 2 - } + }, + "outcome": { + "result": { + "deletedCount": 2 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 } + ] } - ] -} + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/write/deleteMany.json b/source/crud/tests/write/deleteMany.json index 17013b12c1..885ebd200a 100644 --- a/source/crud/tests/write/deleteMany.json +++ b/source/crud/tests/write/deleteMany.json @@ -1,76 +1,76 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ], + "tests": [ + { + "description": "DeleteMany when many documents match", + "operation": { + "name": "deleteMany", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + } } - ], - "tests": [ - { - "description": "DeleteMany when many documents match", - "operation": { - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - } - }, - "name": "deleteMany" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - } - ] - }, - "result": { - "deletedCount": 2 - } + }, + "outcome": { + "result": { + "deletedCount": 2 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 } - }, - { - "description": "DeleteMany when no document matches", - "operation": { - "arguments": { - "filter": { - "_id": 4 - } - }, - "name": "deleteMany" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "deletedCount": 0 - } + ] + } + } + }, + { + "description": "DeleteMany when no document matches", + "operation": { + "name": "deleteMany", + "arguments": { + "filter": { + "_id": 4 + } + } + }, + "outcome": { + "result": { + "deletedCount": 0 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 } + ] } - ] -} + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/write/deleteOne-collation.json b/source/crud/tests/write/deleteOne-collation.json index bd79495223..9f22b1124b 100644 --- a/source/crud/tests/write/deleteOne-collation.json +++ b/source/crud/tests/write/deleteOne-collation.json @@ -1,51 +1,51 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": "ping" - }, - { - "_id": 3, - "x": "pINg" + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": "ping" + }, + { + "_id": 3, + "x": "pINg" + } + ], + "minServerVersion": "3.4", + "tests": [ + { + "description": "DeleteOne when many documents matches with collation", + "operation": { + "name": "deleteOne", + "arguments": { + "filter": { + "x": "PING" + }, + "collation": { + "locale": "en_US", + "strength": 2 + } } - ], - "minServerVersion": "3.4", - "tests": [ - { - "description": "DeleteOne when many documents matches with collation", - "operation": { - "arguments": { - "collation": { - "locale": "en_US", - "strength": 2 - }, - "filter": { - "x": "PING" - } - }, - "name": "deleteOne" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 3, - "x": "pINg" - } - ] - }, - "result": { - "deletedCount": 1 - } + }, + "outcome": { + "result": { + "deletedCount": 1 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 3, + "x": "pINg" } + ] } - ] -} + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/write/deleteOne.json b/source/crud/tests/write/deleteOne.json index 8e5ba6bb9d..50226bdd5e 100644 --- a/source/crud/tests/write/deleteOne.json +++ b/source/crud/tests/write/deleteOne.json @@ -1,96 +1,96 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ], - "tests": [ - { - "description": "DeleteOne when many documents match", - "operation": { - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - } - }, - "name": "deleteOne" - }, - "outcome": { - "result": { - "deletedCount": 1 - } + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ], + "tests": [ + { + "description": "DeleteOne when many documents match", + "operation": { + "name": "deleteOne", + "arguments": { + "filter": { + "_id": { + "$gt": 1 } - }, - { - "description": "DeleteOne when one document matches", - "operation": { - "arguments": { - "filter": { - "_id": 2 - } - }, - "name": "deleteOne" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "deletedCount": 1 - } + } + } + }, + "outcome": { + "result": { + "deletedCount": 1 + } + } + }, + { + "description": "DeleteOne when one document matches", + "operation": { + "name": "deleteOne", + "arguments": { + "filter": { + "_id": 2 + } + } + }, + "outcome": { + "result": { + "deletedCount": 1 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 3, + "x": 33 } - }, - { - "description": "DeleteOne when no documents match", - "operation": { - "arguments": { - "filter": { - "_id": 4 - } - }, - "name": "deleteOne" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "deletedCount": 0 - } + ] + } + } + }, + { + "description": "DeleteOne when no documents match", + "operation": { + "name": "deleteOne", + "arguments": { + "filter": { + "_id": 4 + } + } + }, + "outcome": { + "result": { + "deletedCount": 0 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 } + ] } - ] -} + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/write/findOneAndDelete-collation.json b/source/crud/tests/write/findOneAndDelete-collation.json index 52f74fb332..e848d754d0 100644 --- a/source/crud/tests/write/findOneAndDelete-collation.json +++ b/source/crud/tests/write/findOneAndDelete-collation.json @@ -1,59 +1,59 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": "ping" - }, - { - "_id": 3, - "x": "pINg" + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": "ping" + }, + { + "_id": 3, + "x": "pINg" + } + ], + "minServerVersion": "3.4", + "tests": [ + { + "description": "FindOneAndDelete when one document matches with collation", + "operation": { + "name": "findOneAndDelete", + "arguments": { + "filter": { + "_id": 2, + "x": "PING" + }, + "projection": { + "x": 1, + "_id": 0 + }, + "sort": { + "x": 1 + }, + "collation": { + "locale": "en_US", + "strength": 2 + } } - ], - "minServerVersion": "3.4", - "tests": [ - { - "description": "FindOneAndDelete when one document matches with collation", - "operation": { - "arguments": { - "collation": { - "locale": "en_US", - "strength": 2 - }, - "filter": { - "_id": 2, - "x": "PING" - }, - "projection": { - "_id": 0, - "x": 1 - }, - "sort": { - "x": 1 - } - }, - "name": "findOneAndDelete" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 3, - "x": "pINg" - } - ] - }, - "result": { - "x": "ping" - } + }, + "outcome": { + "result": { + "x": "ping" + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 3, + "x": "pINg" } + ] } - ] -} + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/write/findOneAndDelete.json b/source/crud/tests/write/findOneAndDelete.json index 271129df82..2bfcc32c69 100644 --- a/source/crud/tests/write/findOneAndDelete.json +++ b/source/crud/tests/write/findOneAndDelete.json @@ -1,127 +1,127 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ], + "tests": [ + { + "description": "FindOneAndDelete when many documents match", + "operation": { + "name": "findOneAndDelete", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "projection": { + "x": 1, + "_id": 0 + }, + "sort": { + "x": 1 + } } - ], - "tests": [ - { - "description": "FindOneAndDelete when many documents match", - "operation": { - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "projection": { - "_id": 0, - "x": 1 - }, - "sort": { - "x": 1 - } - }, - "name": "findOneAndDelete" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "x": 22 - } + }, + "outcome": { + "result": { + "x": 22 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 3, + "x": 33 } - }, - { - "description": "FindOneAndDelete when one document matches", - "operation": { - "arguments": { - "filter": { - "_id": 2 - }, - "projection": { - "_id": 0, - "x": 1 - }, - "sort": { - "x": 1 - } - }, - "name": "findOneAndDelete" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "x": 22 - } + ] + } + } + }, + { + "description": "FindOneAndDelete when one document matches", + "operation": { + "name": "findOneAndDelete", + "arguments": { + "filter": { + "_id": 2 + }, + "projection": { + "x": 1, + "_id": 0 + }, + "sort": { + "x": 1 + } + } + }, + "outcome": { + "result": { + "x": 22 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 3, + "x": 33 } - }, - { - "description": "FindOneAndDelete when no documents match", - "operation": { - "arguments": { - "filter": { - "_id": 4 - }, - "projection": { - "_id": 0, - "x": 1 - }, - "sort": { - "x": 1 - } - }, - "name": "findOneAndDelete" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": null + ] + } + } + }, + { + "description": "FindOneAndDelete when no documents match", + "operation": { + "name": "findOneAndDelete", + "arguments": { + "filter": { + "_id": 4 + }, + "projection": { + "x": 1, + "_id": 0 + }, + "sort": { + "x": 1 + } + } + }, + "outcome": { + "result": null, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 } + ] } - ] -} + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/write/findOneAndReplace-collation.json b/source/crud/tests/write/findOneAndReplace-collation.json index 973279cfe7..5227b0f8fa 100644 --- a/source/crud/tests/write/findOneAndReplace-collation.json +++ b/source/crud/tests/write/findOneAndReplace-collation.json @@ -1,58 +1,58 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": "ping" + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": "ping" + } + ], + "minServerVersion": "3.4", + "tests": [ + { + "description": "FindOneAndReplace when one document matches with collation returning the document after modification", + "operation": { + "name": "findOneAndReplace", + "arguments": { + "filter": { + "x": "PING" + }, + "replacement": { + "x": "pong" + }, + "projection": { + "x": 1, + "_id": 0 + }, + "returnDocument": "After", + "sort": { + "x": 1 + }, + "collation": { + "locale": "en_US", + "strength": 2 + } } - ], - "minServerVersion": "3.4", - "tests": [ - { - "description": "FindOneAndReplace when one document matches with collation returning the document after modification", - "operation": { - "arguments": { - "collation": { - "locale": "en_US", - "strength": 2 - }, - "filter": { - "x": "PING" - }, - "projection": { - "_id": 0, - "x": 1 - }, - "replacement": { - "x": "pong" - }, - "returnDocument": "After", - "sort": { - "x": 1 - } - }, - "name": "findOneAndReplace" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": "pong" - } - ] - }, - "result": { - "x": "pong" - } + }, + "outcome": { + "result": { + "x": "pong" + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": "pong" } + ] } - ] -} + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/write/findOneAndReplace-upsert.json b/source/crud/tests/write/findOneAndReplace-upsert.json index ce1a521056..e13eb9c2ba 100644 --- a/source/crud/tests/write/findOneAndReplace-upsert.json +++ b/source/crud/tests/write/findOneAndReplace-upsert.json @@ -1,112 +1,201 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ], + "minServerVersion": "2.6", + "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 } - ], - "minServerVersion": "2.6", - "tests": [ - { - "description": "FindOneAndReplace when no documents match with upsert returning the document before modification", - "operation": { - "arguments": { - "filter": { - "_id": 4 - }, - "projection": { - "_id": 0, - "x": 1 - }, - "replacement": { - "x": 44 - }, - "sort": { - "x": 1 - }, - "upsert": true - }, - "name": "findOneAndReplace" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - }, - { - "_id": 4, - "x": 44 - } - ] - }, - "result": null + }, + "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 upsert returning the document after modification", - "operation": { - "arguments": { - "filter": { - "_id": 4 - }, - "projection": { - "_id": 0, - "x": 1 - }, - "replacement": { - "x": 44 - }, - "returnDocument": "After", - "sort": { - "x": 1 - }, - "upsert": true - }, - "name": "findOneAndReplace" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - }, - { - "_id": 4, - "x": 44 - } - ] - }, - "result": { - "x": 44 - } + ] + } + } + }, + { + "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 + }, + "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 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 diff --git a/source/crud/tests/write/findOneAndReplace-upsert.yml b/source/crud/tests/write/findOneAndReplace-upsert.yml index 481d5ebe65..2bd64c94ec 100644 --- a/source/crud/tests/write/findOneAndReplace-upsert.yml +++ b/source/crud/tests/write/findOneAndReplace-upsert.yml @@ -3,18 +3,20 @@ data: - {_id: 2, x: 22} - {_id: 3, x: 33} minServerVersion: '2.6' -# See SERVER-5289 for why the collection data is only checked for server versions >= 2.6 tests: - - description: "FindOneAndReplace when no documents match with upsert returning the document before modification" + 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} - sort: {x: 1} + # Omit the sort option as it has no effect when no documents + # match and would only cause an inconsistent return value on + # pre-3.0 servers when combined with returnDocument "before" + # (see: SERVER-17650). upsert: true outcome: @@ -26,7 +28,7 @@ tests: - {_id: 3, x: 33} - {_id: 4, x: 44} - - description: "FindOneAndReplace when no documents match with upsert returning the document after modification" + description: "FindOneAndReplace when no documents match without id specified with upsert returning the document after modification" operation: name: findOneAndReplace arguments: @@ -45,3 +47,45 @@ tests: - {_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 before modification" + operation: + name: findOneAndReplace + arguments: + filter: {_id: 4} + replacement: {_id: 4, x: 44} + projection: {x: 1, _id: 0} + # Omit the sort option as it has no effect when no documents + # match and would only cause an inconsistent return value on + # pre-3.0 servers when combined with returnDocument "before" + # (see: SERVER-17650). + 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} diff --git a/source/crud/tests/write/findOneAndReplace-upsert_pre_2.6.json b/source/crud/tests/write/findOneAndReplace-upsert_pre_2.6.json new file mode 100644 index 0000000000..613c664bff --- /dev/null +++ b/source/crud/tests/write/findOneAndReplace-upsert_pre_2.6.json @@ -0,0 +1,161 @@ +{ + "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 diff --git a/source/crud/tests/write/findOneAndReplace-upsert_pre_2.6.yml b/source/crud/tests/write/findOneAndReplace-upsert_pre_2.6.yml new file mode 100644 index 0000000000..f081408632 --- /dev/null +++ b/source/crud/tests/write/findOneAndReplace-upsert_pre_2.6.yml @@ -0,0 +1,88 @@ +data: + - {_id: 1, x: 11} + - {_id: 2, x: 22} + - {_id: 3, x: 33} +# This file includes the same test cases as findOneAndReplace-upsert.yml with +# some omissions for pre-2.6 servers. We cannot verify the ID of an upserted +# document in some cases due to SERVER-5289. +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} + # Omit the sort option as it has no effect when no documents + # match and would only cause an inconsistent return value on + # pre-3.0 servers when combined with returnDocument "before" + # (see: SERVER-17650). + upsert: true + + outcome: + result: null + # Can't verify collection data because server versions before 2.6 do + # not take the _id from the filter document during an upsert (see: + # SERVER-5289). + - + 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} + # Can't verify collection data because server versions before 2.6 do + # not take the _id from the filter document during an upsert (see: + # SERVER-5289). + - + 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} + # Omit the sort option as it has no effect when no documents + # match and would only cause an inconsistent return value on + # pre-3.0 servers when combined with returnDocument "before" + # (see: SERVER-17650). + 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} diff --git a/source/crud/tests/write/findOneAndReplace.json b/source/crud/tests/write/findOneAndReplace.json index 15732dc98b..f8eb5ebb66 100644 --- a/source/crud/tests/write/findOneAndReplace.json +++ b/source/crud/tests/write/findOneAndReplace.json @@ -1,326 +1,273 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ], - "tests": [ - { - "description": "FindOneAndReplace when many documents match returning the document before modification", - "operation": { - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "projection": { - "_id": 0, - "x": 1 - }, - "replacement": { - "x": 32 - }, - "sort": { - "x": 1 - } - }, - "name": "findOneAndReplace" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 32 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "x": 22 - } + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ], + "tests": [ + { + "description": "FindOneAndReplace when many documents match returning the document before modification", + "operation": { + "name": "findOneAndReplace", + "arguments": { + "filter": { + "_id": { + "$gt": 1 } - }, - { - "description": "FindOneAndReplace when many documents match returning the document after modification", - "operation": { - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "projection": { - "_id": 0, - "x": 1 - }, - "replacement": { - "x": 32 - }, - "returnDocument": "After", - "sort": { - "x": 1 - } - }, - "name": "findOneAndReplace" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 32 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "x": 32 - } + }, + "replacement": { + "x": 32 + }, + "projection": { + "x": 1, + "_id": 0 + }, + "sort": { + "x": 1 + } + } + }, + "outcome": { + "result": { + "x": 22 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 32 + }, + { + "_id": 3, + "x": 33 } - }, - { - "description": "FindOneAndReplace when one document matches returning the document before modification", - "operation": { - "arguments": { - "filter": { - "_id": 2 - }, - "projection": { - "_id": 0, - "x": 1 - }, - "replacement": { - "x": 32 - }, - "sort": { - "x": 1 - } - }, - "name": "findOneAndReplace" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 32 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "x": 22 - } + ] + } + } + }, + { + "description": "FindOneAndReplace when many documents match returning the document after modification", + "operation": { + "name": "findOneAndReplace", + "arguments": { + "filter": { + "_id": { + "$gt": 1 } - }, - { - "description": "FindOneAndReplace when one document matches returning the document after modification", - "operation": { - "arguments": { - "filter": { - "_id": 2 - }, - "projection": { - "_id": 0, - "x": 1 - }, - "replacement": { - "x": 32 - }, - "returnDocument": "After", - "sort": { - "x": 1 - } - }, - "name": "findOneAndReplace" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 32 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "x": 32 - } + }, + "replacement": { + "x": 32 + }, + "projection": { + "x": 1, + "_id": 0 + }, + "returnDocument": "After", + "sort": { + "x": 1 + } + } + }, + "outcome": { + "result": { + "x": 32 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 32 + }, + { + "_id": 3, + "x": 33 } - }, - { - "description": "FindOneAndReplace when no documents match returning the document before modification", - "operation": { - "arguments": { - "filter": { - "_id": 4 - }, - "projection": { - "_id": 0, - "x": 1 - }, - "replacement": { - "x": 44 - }, - "sort": { - "x": 1 - } - }, - "name": "findOneAndReplace" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": null + ] + } + } + }, + { + "description": "FindOneAndReplace when one document matches returning the document before modification", + "operation": { + "name": "findOneAndReplace", + "arguments": { + "filter": { + "_id": 2 + }, + "replacement": { + "x": 32 + }, + "projection": { + "x": 1, + "_id": 0 + }, + "sort": { + "x": 1 + } + } + }, + "outcome": { + "result": { + "x": 22 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 32 + }, + { + "_id": 3, + "x": 33 } - }, - { - "description": "FindOneAndReplace when no documents match with upsert returning the document before modification", - "operation": { - "arguments": { - "filter": { - "_id": 4 - }, - "projection": { - "_id": 0, - "x": 1 - }, - "replacement": { - "x": 44 - }, - "sort": { - "x": 1 - }, - "upsert": true - }, - "name": "findOneAndReplace" - }, - "outcome": { - "result": null + ] + } + } + }, + { + "description": "FindOneAndReplace when one document matches returning the document after modification", + "operation": { + "name": "findOneAndReplace", + "arguments": { + "filter": { + "_id": 2 + }, + "replacement": { + "x": 32 + }, + "projection": { + "x": 1, + "_id": 0 + }, + "returnDocument": "After", + "sort": { + "x": 1 + } + } + }, + "outcome": { + "result": { + "x": 32 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 32 + }, + { + "_id": 3, + "x": 33 } - }, - { - "description": "FindOneAndReplace when no documents match returning the document after modification", - "operation": { - "arguments": { - "filter": { - "_id": 4 - }, - "projection": { - "_id": 0, - "x": 1 - }, - "replacement": { - "x": 44 - }, - "returnDocument": "After", - "sort": { - "x": 1 - } - }, - "name": "findOneAndReplace" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": null + ] + } + } + }, + { + "description": "FindOneAndReplace when no documents match returning the document before modification", + "operation": { + "name": "findOneAndReplace", + "arguments": { + "filter": { + "_id": 4 + }, + "replacement": { + "x": 44 + }, + "projection": { + "x": 1, + "_id": 0 + }, + "sort": { + "x": 1 + } + } + }, + "outcome": { + "result": null, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 } - }, - { - "description": "FindOneAndReplace when no documents match with upsert returning the document after modification", - "operation": { - "arguments": { - "filter": { - "_id": 4 - }, - "projection": { - "_id": 0, - "x": 1 - }, - "replacement": { - "x": 44 - }, - "returnDocument": "After", - "sort": { - "x": 1 - }, - "upsert": true - }, - "name": "findOneAndReplace" - }, - "outcome": { - "result": { - "x": 44 - } + ] + } + } + }, + { + "description": "FindOneAndReplace when no documents match 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 + } + } + }, + "outcome": { + "result": null, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 } + ] } - ] -} + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/write/findOneAndReplace.yml b/source/crud/tests/write/findOneAndReplace.yml index 149584dab1..c121418b78 100644 --- a/source/crud/tests/write/findOneAndReplace.yml +++ b/source/crud/tests/write/findOneAndReplace.yml @@ -93,20 +93,6 @@ tests: - {_id: 1, x: 11} - {_id: 2, x: 22} - {_id: 3, x: 33} - - - description: "FindOneAndReplace when no documents match with upsert returning the document before modification" - operation: - name: findOneAndReplace - arguments: - filter: {_id: 4} - replacement: {x: 44} - projection: {x: 1, _id: 0} - sort: {x: 1} - upsert: true - - outcome: - result: null - # See SERVER-5289 for why the collection data is not checked for server versions < 2.6 - description: "FindOneAndReplace when no documents match returning the document after modification" operation: @@ -125,18 +111,3 @@ tests: - {_id: 1, x: 11} - {_id: 2, x: 22} - {_id: 3, x: 33} - - - description: "FindOneAndReplace when no documents match 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} - # See SERVER-5289 for why the collection data is not checked for server versions < 2.6 diff --git a/source/crud/tests/write/findOneAndUpdate-collation.json b/source/crud/tests/write/findOneAndUpdate-collation.json index 2ced15cfec..172149ac84 100644 --- a/source/crud/tests/write/findOneAndUpdate-collation.json +++ b/source/crud/tests/write/findOneAndUpdate-collation.json @@ -1,67 +1,67 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": "ping" - }, - { - "_id": 3, - "x": "pINg" + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": "ping" + }, + { + "_id": 3, + "x": "pINg" + } + ], + "minServerVersion": "3.4", + "tests": [ + { + "description": "FindOneAndUpdate when many documents match with collation returning the document before modification", + "operation": { + "name": "findOneAndUpdate", + "arguments": { + "filter": { + "x": "PING" + }, + "update": { + "$set": { + "x": "pong" + } + }, + "projection": { + "x": 1, + "_id": 0 + }, + "sort": { + "_id": 1 + }, + "collation": { + "locale": "en_US", + "strength": 2 + } } - ], - "minServerVersion": "3.4", - "tests": [ - { - "description": "FindOneAndUpdate when many documents match with collation returning the document before modification", - "operation": { - "arguments": { - "collation": { - "locale": "en_US", - "strength": 2 - }, - "filter": { - "x": "PING" - }, - "projection": { - "_id": 0, - "x": 1 - }, - "sort": { - "_id": 1 - }, - "update": { - "$set": { - "x": "pong" - } - } - }, - "name": "findOneAndUpdate" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": "pong" - }, - { - "_id": 3, - "x": "pINg" - } - ] - }, - "result": { - "x": "ping" - } + }, + "outcome": { + "result": { + "x": "ping" + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": "pong" + }, + { + "_id": 3, + "x": "pINg" } + ] } - ] -} + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/write/findOneAndUpdate.json b/source/crud/tests/write/findOneAndUpdate.json index 7b59fa0de4..c257b74023 100644 --- a/source/crud/tests/write/findOneAndUpdate.json +++ b/source/crud/tests/write/findOneAndUpdate.json @@ -1,382 +1,379 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ], + "tests": [ + { + "description": "FindOneAndUpdate when many documents match returning the document before modification", + "operation": { + "name": "findOneAndUpdate", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "update": { + "$inc": { + "x": 1 + } + }, + "projection": { + "x": 1, + "_id": 0 + }, + "sort": { + "x": 1 + } + } + }, + "outcome": { + "result": { + "x": 22 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 23 + }, + { + "_id": 3, + "x": 33 + } + ] + } + } + }, + { + "description": "FindOneAndUpdate when many documents match returning the document after modification", + "operation": { + "name": "findOneAndUpdate", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "update": { + "$inc": { + "x": 1 + } + }, + "projection": { + "x": 1, + "_id": 0 + }, + "returnDocument": "After", + "sort": { + "x": 1 + } + } + }, + "outcome": { + "result": { + "x": 23 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 23 + }, + { + "_id": 3, + "x": 33 + } + ] + } + } + }, + { + "description": "FindOneAndUpdate when one document matches returning the document before modification", + "operation": { + "name": "findOneAndUpdate", + "arguments": { + "filter": { + "_id": 2 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "projection": { + "x": 1, + "_id": 0 + }, + "sort": { + "x": 1 + } + } + }, + "outcome": { + "result": { + "x": 22 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 23 + }, + { + "_id": 3, + "x": 33 + } + ] + } + } + }, + { + "description": "FindOneAndUpdate when one document matches returning the document after modification", + "operation": { + "name": "findOneAndUpdate", + "arguments": { + "filter": { + "_id": 2 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "projection": { + "x": 1, + "_id": 0 + }, + "returnDocument": "After", + "sort": { + "x": 1 + } } - ], - "tests": [ - { - "description": "FindOneAndUpdate when many documents match returning the document before modification", - "operation": { - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "projection": { - "_id": 0, - "x": 1 - }, - "sort": { - "x": 1 - }, - "update": { - "$inc": { - "x": 1 - } - } - }, - "name": "findOneAndUpdate" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 23 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "x": 22 - } + }, + "outcome": { + "result": { + "x": 23 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 23 + }, + { + "_id": 3, + "x": 33 } - }, - { - "description": "FindOneAndUpdate when many documents match returning the document after modification", - "operation": { - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "projection": { - "_id": 0, - "x": 1 - }, - "returnDocument": "After", - "sort": { - "x": 1 - }, - "update": { - "$inc": { - "x": 1 - } - } - }, - "name": "findOneAndUpdate" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 23 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "x": 23 - } + ] + } + } + }, + { + "description": "FindOneAndUpdate when no documents match returning the document before modification", + "operation": { + "name": "findOneAndUpdate", + "arguments": { + "filter": { + "_id": 4 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "projection": { + "x": 1, + "_id": 0 + }, + "sort": { + "x": 1 + } + } + }, + "outcome": { + "result": null, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 } - }, - { - "description": "FindOneAndUpdate when one document matches returning the document before modification", - "operation": { - "arguments": { - "filter": { - "_id": 2 - }, - "projection": { - "_id": 0, - "x": 1 - }, - "sort": { - "x": 1 - }, - "update": { - "$inc": { - "x": 1 - } - } - }, - "name": "findOneAndUpdate" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 23 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "x": 22 - } + ] + } + } + }, + { + "description": "FindOneAndUpdate when no documents match with upsert returning the document before modification", + "operation": { + "name": "findOneAndUpdate", + "arguments": { + "filter": { + "_id": 4 + }, + "update": { + "$inc": { + "x": 1 } - }, - { - "description": "FindOneAndUpdate when one document matches returning the document after modification", - "operation": { - "arguments": { - "filter": { - "_id": 2 - }, - "projection": { - "_id": 0, - "x": 1 - }, - "returnDocument": "After", - "sort": { - "x": 1 - }, - "update": { - "$inc": { - "x": 1 - } - } - }, - "name": "findOneAndUpdate" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 23 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "x": 23 - } + }, + "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": 1 } - }, - { - "description": "FindOneAndUpdate when no documents match returning the document before modification", - "operation": { - "arguments": { - "filter": { - "_id": 4 - }, - "projection": { - "_id": 0, - "x": 1 - }, - "sort": { - "x": 1 - }, - "update": { - "$inc": { - "x": 1 - } - } - }, - "name": "findOneAndUpdate" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": null + ] + } + } + }, + { + "description": "FindOneAndUpdate when no documents match returning the document after modification", + "operation": { + "name": "findOneAndUpdate", + "arguments": { + "filter": { + "_id": 4 + }, + "update": { + "$inc": { + "x": 1 } - }, - { - "description": "FindOneAndUpdate when no documents match with upsert returning the document before modification", - "operation": { - "arguments": { - "filter": { - "_id": 4 - }, - "projection": { - "_id": 0, - "x": 1 - }, - "sort": { - "x": 1 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "upsert": true - }, - "name": "findOneAndUpdate" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - }, - { - "_id": 4, - "x": 1 - } - ] - }, - "result": null + }, + "projection": { + "x": 1, + "_id": 0 + }, + "returnDocument": "After", + "sort": { + "x": 1 + } + } + }, + "outcome": { + "result": null, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 } - }, - { - "description": "FindOneAndUpdate when no documents match returning the document after modification", - "operation": { - "arguments": { - "filter": { - "_id": 4 - }, - "projection": { - "_id": 0, - "x": 1 - }, - "returnDocument": "After", - "sort": { - "x": 1 - }, - "update": { - "$inc": { - "x": 1 - } - } - }, - "name": "findOneAndUpdate" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": null + ] + } + } + }, + { + "description": "FindOneAndUpdate when no documents match with upsert returning the document after modification", + "operation": { + "name": "findOneAndUpdate", + "arguments": { + "filter": { + "_id": 4 + }, + "update": { + "$inc": { + "x": 1 } - }, - { - "description": "FindOneAndUpdate when no documents match with upsert returning the document after modification", - "operation": { - "arguments": { - "filter": { - "_id": 4 - }, - "projection": { - "_id": 0, - "x": 1 - }, - "returnDocument": "After", - "sort": { - "x": 1 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "upsert": true - }, - "name": "findOneAndUpdate" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - }, - { - "_id": 4, - "x": 1 - } - ] - }, - "result": { - "x": 1 - } + }, + "projection": { + "x": 1, + "_id": 0 + }, + "returnDocument": "After", + "sort": { + "x": 1 + }, + "upsert": true + } + }, + "outcome": { + "result": { + "x": 1 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + }, + { + "_id": 4, + "x": 1 } + ] } - ] -} + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/write/findOneAndUpdate.yml b/source/crud/tests/write/findOneAndUpdate.yml index 430f6a4f1c..bed02f146a 100644 --- a/source/crud/tests/write/findOneAndUpdate.yml +++ b/source/crud/tests/write/findOneAndUpdate.yml @@ -107,7 +107,10 @@ tests: update: $inc: {x: 1} projection: {x: 1, _id: 0} - sort: {x: 1} + # Omit the sort option as it has no effect when no documents + # match and would only cause an inconsistent return value on + # pre-3.0 servers when combined with returnDocument "before" + # (see: SERVER-17650). upsert: true outcome: diff --git a/source/crud/tests/write/insertMany.json b/source/crud/tests/write/insertMany.json index 2c488cac21..f604ef75fc 100644 --- a/source/crud/tests/write/insertMany.json +++ b/source/crud/tests/write/insertMany.json @@ -1,52 +1,52 @@ { - "data": [ - { - "_id": 1, - "x": 11 + "data": [ + { + "_id": 1, + "x": 11 + } + ], + "tests": [ + { + "description": "InsertMany with non-existing documents", + "operation": { + "name": "insertMany", + "arguments": { + "documents": [ + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] } - ], - "tests": [ - { - "description": "InsertMany with non-existing documents", - "operation": { - "arguments": { - "documents": [ - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "name": "insertMany" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "insertedIds": [ - 2, - 3 - ] - } + }, + "outcome": { + "result": { + "insertedIds": [ + 2, + 3 + ] + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 } + ] } - ] -} + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/write/insertOne.json b/source/crud/tests/write/insertOne.json index 225f8f3ac7..83597fca8c 100644 --- a/source/crud/tests/write/insertOne.json +++ b/source/crud/tests/write/insertOne.json @@ -1,39 +1,39 @@ { - "data": [ - { - "_id": 1, - "x": 11 + "data": [ + { + "_id": 1, + "x": 11 + } + ], + "tests": [ + { + "description": "InsertOne with a non-existing document", + "operation": { + "name": "insertOne", + "arguments": { + "document": { + "_id": 2, + "x": 22 + } } - ], - "tests": [ - { - "description": "InsertOne with a non-existing document", - "operation": { - "arguments": { - "document": { - "_id": 2, - "x": 22 - } - }, - "name": "insertOne" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - } - ] - }, - "result": { - "insertedId": 2 - } + }, + "outcome": { + "result": { + "insertedId": 2 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 } + ] } - ] -} + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/write/replaceOne-collation.json b/source/crud/tests/write/replaceOne-collation.json index 4bfc075dd2..c2a08c9b14 100644 --- a/source/crud/tests/write/replaceOne-collation.json +++ b/source/crud/tests/write/replaceOne-collation.json @@ -1,52 +1,53 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": "ping" + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": "ping" + } + ], + "minServerVersion": "3.4", + "tests": [ + { + "description": "ReplaceOne when one document matches with collation", + "operation": { + "name": "replaceOne", + "arguments": { + "filter": { + "x": "PING" + }, + "replacement": { + "_id": 2, + "x": "pong" + }, + "collation": { + "locale": "en_US", + "strength": 2 + } } - ], - "minServerVersion": "3.4", - "tests": [ - { - "description": "ReplaceOne when one document matches with collation", - "operation": { - "arguments": { - "collation": { - "locale": "en_US", - "strength": 2 - }, - "filter": { - "x": "PING" - }, - "replacement": { - "_id": 2, - "x": "pong" - } - }, - "name": "replaceOne" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": "pong" - } - ] - }, - "result": { - "matchedCount": 1, - "modifiedCount": 1 - } + }, + "outcome": { + "result": { + "matchedCount": 1, + "modifiedCount": 1, + "upsertedCount": 0 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": "pong" } + ] } - ] -} + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/write/replaceOne-collation.yml b/source/crud/tests/write/replaceOne-collation.yml index 057f2dcea6..6861092bbb 100644 --- a/source/crud/tests/write/replaceOne-collation.yml +++ b/source/crud/tests/write/replaceOne-collation.yml @@ -17,6 +17,7 @@ tests: result: matchedCount: 1 modifiedCount: 1 + upsertedCount: 0 collection: data: - {_id: 1, x: 11} diff --git a/source/crud/tests/write/replaceOne-pre_2.6.json b/source/crud/tests/write/replaceOne-pre_2.6.json new file mode 100644 index 0000000000..363bad50b0 --- /dev/null +++ b/source/crud/tests/write/replaceOne-pre_2.6.json @@ -0,0 +1,179 @@ +{ + "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 diff --git a/source/crud/tests/write/replaceOne-pre_2.6.yml b/source/crud/tests/write/replaceOne-pre_2.6.yml new file mode 100644 index 0000000000..918a3b639b --- /dev/null +++ b/source/crud/tests/write/replaceOne-pre_2.6.yml @@ -0,0 +1,98 @@ +data: + - {_id: 1, x: 11} + - {_id: 2, x: 22} + - {_id: 3, x: 33} +# This file includes the same test cases as replaceOne.yml with some omissions +# for pre-2.6 servers. We cannot verify the update result's modifiedCount as it +# is not available with legacy write operations and getLastError. Additionally, +# we cannot verify the ID of an upserted document in some cases due to +# SERVER-5289. +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 + # Can't verify collection data because we don't have a way of + # knowing which document gets updated. + - + 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 + # Can't verify upsertedId or collection data because server versions + # before 2.6 do not take the _id from the filter document during an + # upsert (see: SERVER-5289) + + - + 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} diff --git a/source/crud/tests/write/replaceOne-upsert.json b/source/crud/tests/write/replaceOne-upsert.json deleted file mode 100644 index f3040dcc91..0000000000 --- a/source/crud/tests/write/replaceOne-upsert.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "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 - } - } - } - ] -} diff --git a/source/crud/tests/write/replaceOne-upsert.yml b/source/crud/tests/write/replaceOne-upsert.yml deleted file mode 100644 index 03c323f03a..0000000000 --- a/source/crud/tests/write/replaceOne-upsert.yml +++ /dev/null @@ -1,48 +0,0 @@ -data: - - {_id: 1, x: 11} - - {_id: 2, x: 22} - - {_id: 3, x: 33} -minServerVersion: '2.6' -# See SERVER-5289 for why the collection data is only checked for server versions >= 2.6 - -tests: - - - 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 - modifiedCount: 0 - upsertedId: 4 - collection: - data: - - {_id: 1, x: 11} - - {_id: 2, x: 22} - - {_id: 3, x: 33} - - {_id: 4, x: 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 - modifiedCount: 0 - upsertedId: 4 - collection: - data: - - {_id: 1, x: 11} - - {_id: 2, x: 22} - - {_id: 3, x: 33} - - {_id: 4, x: 1} diff --git a/source/crud/tests/write/replaceOne.json b/source/crud/tests/write/replaceOne.json index c821153528..580e3b9394 100644 --- a/source/crud/tests/write/replaceOne.json +++ b/source/crud/tests/write/replaceOne.json @@ -1,159 +1,205 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ], - "tests": [ - { - "description": "ReplaceOne when many documents match", - "operation": { - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "replacement": { - "x": 111 - } - }, - "name": "replaceOne" - }, - "outcome": { - "result": { - "matchedCount": 1, - "modifiedCount": 1 - } + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ], + "minServerVersion": "2.6", + "tests": [ + { + "description": "ReplaceOne when many documents match", + "operation": { + "name": "replaceOne", + "arguments": { + "filter": { + "_id": { + "$gt": 1 } - }, - { - "description": "ReplaceOne when one document matches", - "operation": { - "arguments": { - "filter": { - "_id": 1 - }, - "replacement": { - "_id": 1, - "x": 111 - } - }, - "name": "replaceOne" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 111 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "matchedCount": 1, - "modifiedCount": 1 - } + }, + "replacement": { + "x": 111 + } + } + }, + "outcome": { + "result": { + "matchedCount": 1, + "modifiedCount": 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, + "modifiedCount": 1, + "upsertedCount": 0 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 111 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 } - }, - { - "description": "ReplaceOne when no documents match", - "operation": { - "arguments": { - "filter": { - "_id": 4 - }, - "replacement": { - "_id": 4, - "x": 1 - } - }, - "name": "replaceOne" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "matchedCount": 0, - "modifiedCount": 0 - } + ] + } + } + }, + { + "description": "ReplaceOne when no documents match", + "operation": { + "name": "replaceOne", + "arguments": { + "filter": { + "_id": 4 + }, + "replacement": { + "_id": 4, + "x": 1 + } + } + }, + "outcome": { + "result": { + "matchedCount": 0, + "modifiedCount": 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": { - "arguments": { - "filter": { - "_id": 4 - }, - "replacement": { - "x": 1 - }, - "upsert": true - }, - "name": "replaceOne" - }, - "outcome": { - "result": { - "matchedCount": 0, - "modifiedCount": 0, - "upsertedId": 4 - } + ] + } + } + }, + { + "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, + "modifiedCount": 0, + "upsertedCount": 1, + "upsertedId": 4 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + }, + { + "_id": 4, + "x": 1 } - }, - { - "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": { - "result": { - "matchedCount": 0, - "modifiedCount": 0, - "upsertedId": 4 - } + ] + } + } + }, + { + "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, + "modifiedCount": 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 diff --git a/source/crud/tests/write/replaceOne.yml b/source/crud/tests/write/replaceOne.yml index a32feecfb1..4bccd36008 100644 --- a/source/crud/tests/write/replaceOne.yml +++ b/source/crud/tests/write/replaceOne.yml @@ -2,6 +2,7 @@ data: - {_id: 1, x: 11} - {_id: 2, x: 22} - {_id: 3, x: 33} +minServerVersion: '2.6' tests: - @@ -17,8 +18,9 @@ tests: result: matchedCount: 1 modifiedCount: 1 - # can't verify collection because we don't have a way - # of knowing which document gets updated. + upsertedCount: 0 + # Can't verify collection data because we don't have a way of + # knowing which document gets updated. - description: "ReplaceOne when one document matches" operation: @@ -31,6 +33,7 @@ tests: result: matchedCount: 1 modifiedCount: 1 + upsertedCount: 0 collection: data: - {_id: 1, x: 111} @@ -48,6 +51,7 @@ tests: result: matchedCount: 0 modifiedCount: 0 + upsertedCount: 0 collection: data: - {_id: 1, x: 11} @@ -66,8 +70,14 @@ tests: result: matchedCount: 0 modifiedCount: 0 + upsertedCount: 1 upsertedId: 4 - # See SERVER-5289 for why the collection data is not checked for server versions < 2.6 + collection: + data: + - {_id: 1, x: 11} + - {_id: 2, x: 22} + - {_id: 3, x: 33} + - {_id: 4, x: 1} - description: "ReplaceOne with upsert when no documents match with an id specified" @@ -82,5 +92,11 @@ tests: result: matchedCount: 0 modifiedCount: 0 + upsertedCount: 1 upsertedId: 4 - # See SERVER-5289 for why the collection data is not checked for server versions < 2.6 + collection: + data: + - {_id: 1, x: 11} + - {_id: 2, x: 22} + - {_id: 3, x: 33} + - {_id: 4, x: 1} diff --git a/source/crud/tests/write/updateMany-collation.json b/source/crud/tests/write/updateMany-collation.json index 829a3f6b02..d88ce60fcf 100644 --- a/source/crud/tests/write/updateMany-collation.json +++ b/source/crud/tests/write/updateMany-collation.json @@ -1,61 +1,62 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": "ping" + }, + { + "_id": 3, + "x": "pINg" + } + ], + "minServerVersion": "3.4", + "tests": [ + { + "description": "UpdateMany when many documents match with collation", + "operation": { + "name": "updateMany", + "arguments": { + "filter": { "x": "ping" - }, - { - "_id": 3, - "x": "pINg" + }, + "update": { + "$set": { + "x": "pong" + } + }, + "collation": { + "locale": "en_US", + "strength": 2 + } } - ], - "minServerVersion": "3.4", - "tests": [ - { - "description": "UpdateMany when many documents match with collation", - "operation": { - "arguments": { - "collation": { - "locale": "en_US", - "strength": 2 - }, - "filter": { - "x": "ping" - }, - "update": { - "$set": { - "x": "pong" - } - } - }, - "name": "updateMany" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": "pong" - }, - { - "_id": 3, - "x": "pong" - } - ] - }, - "result": { - "matchedCount": 2, - "modifiedCount": 2 - } + }, + "outcome": { + "result": { + "matchedCount": 2, + "modifiedCount": 2, + "upsertedCount": 0 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": "pong" + }, + { + "_id": 3, + "x": "pong" } + ] } - ] -} + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/write/updateMany-collation.yml b/source/crud/tests/write/updateMany-collation.yml index 9b4fe986ad..2d48a9dcfe 100644 --- a/source/crud/tests/write/updateMany-collation.yml +++ b/source/crud/tests/write/updateMany-collation.yml @@ -20,6 +20,7 @@ tests: result: matchedCount: 2 modifiedCount: 2 + upsertedCount: 0 collection: data: - {_id: 1, x: 11} diff --git a/source/crud/tests/write/updateMany-pre_2.6.json b/source/crud/tests/write/updateMany-pre_2.6.json new file mode 100644 index 0000000000..89e8a5c915 --- /dev/null +++ b/source/crud/tests/write/updateMany-pre_2.6.json @@ -0,0 +1,179 @@ +{ + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ], + "maxServerVersion": "2.4.99", + "tests": [ + { + "description": "UpdateMany when many documents match", + "operation": { + "name": "updateMany", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "update": { + "$inc": { + "x": 1 + } + } + } + }, + "outcome": { + "result": { + "matchedCount": 2, + "upsertedCount": 0 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 23 + }, + { + "_id": 3, + "x": 34 + } + ] + } + } + }, + { + "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 + }, + { + "_id": 3, + "x": 33 + } + ] + } + } + }, + { + "description": "UpdateMany when no documents match", + "operation": { + "name": "updateMany", + "arguments": { + "filter": { + "_id": 4 + }, + "update": { + "$inc": { + "x": 1 + } + } + } + }, + "outcome": { + "result": { + "matchedCount": 0, + "upsertedCount": 0 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + } + }, + { + "description": "UpdateMany with upsert when no documents match", + "operation": { + "name": "updateMany", + "arguments": { + "filter": { + "_id": 4 + }, + "update": { + "$inc": { + "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 diff --git a/source/crud/tests/write/updateMany-pre_2.6.yml b/source/crud/tests/write/updateMany-pre_2.6.yml new file mode 100644 index 0000000000..429219a40c --- /dev/null +++ b/source/crud/tests/write/updateMany-pre_2.6.yml @@ -0,0 +1,86 @@ +data: + - {_id: 1, x: 11} + - {_id: 2, x: 22} + - {_id: 3, x: 33} +# This file includes the same test cases as updateMany.yml with some omissions +# for pre-2.6 servers. We cannot verify the update result's modifiedCount as it +# is not available with legacy write operations and getLastError. +maxServerVersion: '2.4.99' + +tests: + - + description: "UpdateMany when many documents match" + operation: + name: "updateMany" + arguments: + filter: + _id: {$gt: 1} + update: + $inc: {x: 1} + + outcome: + result: + matchedCount: 2 + upsertedCount: 0 + collection: + data: + - {_id: 1, x: 11} + - {_id: 2, x: 23} + - {_id: 3, x: 34} + - + 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} + - {_id: 3, x: 33} + - + description: "UpdateMany when no documents match" + operation: + name: "updateMany" + arguments: + filter: {_id: 4} + update: + $inc: {x: 1} + + outcome: + result: + matchedCount: 0 + upsertedCount: 0 + collection: + data: + - {_id: 1, x: 11} + - {_id: 2, x: 22} + - {_id: 3, x: 33} + - + description: "UpdateMany with upsert when no documents match" + operation: + name: "updateMany" + arguments: + filter: {_id: 4} + update: + $inc: {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} diff --git a/source/crud/tests/write/updateMany.json b/source/crud/tests/write/updateMany.json index 6a0b3139a2..533e3f308f 100644 --- a/source/crud/tests/write/updateMany.json +++ b/source/crud/tests/write/updateMany.json @@ -1,178 +1,183 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ], + "minServerVersion": "2.6", + "tests": [ + { + "description": "UpdateMany when many documents match", + "operation": { + "name": "updateMany", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "update": { + "$inc": { + "x": 1 + } + } + } + }, + "outcome": { + "result": { + "matchedCount": 2, + "modifiedCount": 2, + "upsertedCount": 0 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 23 + }, + { + "_id": 3, + "x": 34 + } + ] } - ], - "tests": [ - { - "description": "UpdateMany when many documents match", - "operation": { - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "update": { - "$inc": { - "x": 1 - } - } - }, - "name": "updateMany" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 23 - }, - { - "_id": 3, - "x": 34 - } - ] - }, - "result": { - "matchedCount": 2, - "modifiedCount": 2 - } + } + }, + { + "description": "UpdateMany when one document matches", + "operation": { + "name": "updateMany", + "arguments": { + "filter": { + "_id": 1 + }, + "update": { + "$inc": { + "x": 1 } - }, - { - "description": "UpdateMany when one document matches", - "operation": { - "arguments": { - "filter": { - "_id": 1 - }, - "update": { - "$inc": { - "x": 1 - } - } - }, - "name": "updateMany" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 12 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "matchedCount": 1, - "modifiedCount": 1 - } + } + } + }, + "outcome": { + "result": { + "matchedCount": 1, + "modifiedCount": 1, + "upsertedCount": 0 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 12 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 } - }, - { - "description": "UpdateMany when no documents match", - "operation": { - "arguments": { - "filter": { - "_id": 4 - }, - "update": { - "$inc": { - "x": 1 - } - } - }, - "name": "updateMany" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "matchedCount": 0, - "modifiedCount": 0 - } + ] + } + } + }, + { + "description": "UpdateMany when no documents match", + "operation": { + "name": "updateMany", + "arguments": { + "filter": { + "_id": 4 + }, + "update": { + "$inc": { + "x": 1 } - }, - { - "description": "UpdateMany with upsert when no documents match", - "operation": { - "arguments": { - "filter": { - "_id": 4 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "upsert": true - }, - "name": "updateMany" - }, - "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 - } + } + } + }, + "outcome": { + "result": { + "matchedCount": 0, + "modifiedCount": 0, + "upsertedCount": 0 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + } + }, + { + "description": "UpdateMany with upsert when no documents match", + "operation": { + "name": "updateMany", + "arguments": { + "filter": { + "_id": 4 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "upsert": true + } + }, + "outcome": { + "result": { + "matchedCount": 0, + "modifiedCount": 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 diff --git a/source/crud/tests/write/updateMany.yml b/source/crud/tests/write/updateMany.yml index a6d630410a..a0eb62ba83 100644 --- a/source/crud/tests/write/updateMany.yml +++ b/source/crud/tests/write/updateMany.yml @@ -2,6 +2,7 @@ data: - {_id: 1, x: 11} - {_id: 2, x: 22} - {_id: 3, x: 33} +minServerVersion: '2.6' tests: - @@ -18,6 +19,7 @@ tests: result: matchedCount: 2 modifiedCount: 2 + upsertedCount: 0 collection: data: - {_id: 1, x: 11} @@ -36,6 +38,7 @@ tests: result: matchedCount: 1 modifiedCount: 1 + upsertedCount: 0 collection: data: - {_id: 1, x: 12} @@ -54,6 +57,7 @@ tests: result: matchedCount: 0 modifiedCount: 0 + upsertedCount: 0 collection: data: - {_id: 1, x: 11} @@ -73,6 +77,7 @@ tests: result: matchedCount: 0 modifiedCount: 0 + upsertedCount: 1 upsertedId: 4 collection: data: diff --git a/source/crud/tests/write/updateOne-collation.json b/source/crud/tests/write/updateOne-collation.json index aa85936243..8e45ff3280 100644 --- a/source/crud/tests/write/updateOne-collation.json +++ b/source/crud/tests/write/updateOne-collation.json @@ -1,53 +1,54 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": "ping" + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": "ping" + } + ], + "minServerVersion": "3.4", + "tests": [ + { + "description": "UpdateOne when one document matches with collation", + "operation": { + "name": "updateOne", + "arguments": { + "filter": { + "x": "PING" + }, + "update": { + "$set": { + "x": "pong" + } + }, + "collation": { + "locale": "en_US", + "strength": 2 + } } - ], - "minServerVersion": "3.4", - "tests": [ - { - "description": "UpdateOne when one document matches with collation", - "operation": { - "arguments": { - "collation": { - "locale": "en_US", - "strength": 2 - }, - "filter": { - "x": "PING" - }, - "update": { - "$set": { - "x": "pong" - } - } - }, - "name": "updateOne" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": "pong" - } - ] - }, - "result": { - "matchedCount": 1, - "modifiedCount": 1 - } + }, + "outcome": { + "result": { + "matchedCount": 1, + "modifiedCount": 1, + "upsertedCount": 0 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": "pong" } + ] } - ] -} + } + } + ] +} \ No newline at end of file diff --git a/source/crud/tests/write/updateOne-collation.yml b/source/crud/tests/write/updateOne-collation.yml index 63c134d466..468e946742 100644 --- a/source/crud/tests/write/updateOne-collation.yml +++ b/source/crud/tests/write/updateOne-collation.yml @@ -18,6 +18,7 @@ tests: result: matchedCount: 1 modifiedCount: 1 + upsertedCount: 0 collection: data: - {_id: 1, x: 11} diff --git a/source/crud/tests/write/updateOne-pre_2.6.json b/source/crud/tests/write/updateOne-pre_2.6.json new file mode 100644 index 0000000000..de15c61625 --- /dev/null +++ b/source/crud/tests/write/updateOne-pre_2.6.json @@ -0,0 +1,163 @@ +{ + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ], + "maxServerVersion": "2.4.99", + "tests": [ + { + "description": "UpdateOne when many documents match", + "operation": { + "name": "updateOne", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "update": { + "$inc": { + "x": 1 + } + } + } + }, + "outcome": { + "result": { + "matchedCount": 1, + "upsertedCount": 0 + } + } + }, + { + "description": "UpdateOne when one document matches", + "operation": { + "name": "updateOne", + "arguments": { + "filter": { + "_id": 1 + }, + "update": { + "$inc": { + "x": 1 + } + } + } + }, + "outcome": { + "result": { + "matchedCount": 1, + "upsertedCount": 0 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 12 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + } + }, + { + "description": "UpdateOne when no documents match", + "operation": { + "name": "updateOne", + "arguments": { + "filter": { + "_id": 4 + }, + "update": { + "$inc": { + "x": 1 + } + } + } + }, + "outcome": { + "result": { + "matchedCount": 0, + "upsertedCount": 0 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + } + }, + { + "description": "UpdateOne with upsert when no documents match", + "operation": { + "name": "updateOne", + "arguments": { + "filter": { + "_id": 4 + }, + "update": { + "$inc": { + "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 diff --git a/source/crud/tests/write/updateOne-pre_2.6.yml b/source/crud/tests/write/updateOne-pre_2.6.yml new file mode 100644 index 0000000000..8e1dd1626f --- /dev/null +++ b/source/crud/tests/write/updateOne-pre_2.6.yml @@ -0,0 +1,83 @@ +data: + - {_id: 1, x: 11} + - {_id: 2, x: 22} + - {_id: 3, x: 33} +# This file includes the same test cases as updateOne.yml with some omissions +# for pre-2.6 servers. We cannot verify the update result's modifiedCount as it +# is not available with legacy write operations and getLastError. +maxServerVersion: '2.4.99' + +tests: + - + description: "UpdateOne when many documents match" + operation: + name: "updateOne" + arguments: + filter: + _id: {$gt: 1} + update: + $inc: {x: 1} + + outcome: + result: + matchedCount: 1 + upsertedCount: 0 + # Can't verify collection data because we don't have a way of + # knowing which document gets updated. + - + description: "UpdateOne when one document matches" + operation: + name: "updateOne" + arguments: + filter: {_id: 1} + update: + $inc: {x: 1} + + outcome: + result: + matchedCount: 1 + upsertedCount: 0 + collection: + data: + - {_id: 1, x: 12} + - {_id: 2, x: 22} + - {_id: 3, x: 33} + - + description: "UpdateOne when no documents match" + operation: + name: "updateOne" + arguments: + filter: {_id: 4} + update: + $inc: {x: 1} + + outcome: + result: + matchedCount: 0 + upsertedCount: 0 + collection: + data: + - {_id: 1, x: 11} + - {_id: 2, x: 22} + - {_id: 3, x: 33} + - + description: "UpdateOne with upsert when no documents match" + operation: + name: "updateOne" + arguments: + filter: {_id: 4} + update: + $inc: {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} diff --git a/source/crud/tests/write/updateOne.json b/source/crud/tests/write/updateOne.json index a6abdb26d4..1a51dff135 100644 --- a/source/crud/tests/write/updateOne.json +++ b/source/crud/tests/write/updateOne.json @@ -1,162 +1,167 @@ { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ], + "minServerVersion": "2.6", + "tests": [ + { + "description": "UpdateOne when many documents match", + "operation": { + "name": "updateOne", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "update": { + "$inc": { + "x": 1 + } + } + } + }, + "outcome": { + "result": { + "matchedCount": 1, + "modifiedCount": 1, + "upsertedCount": 0 + } + } + }, + { + "description": "UpdateOne when one document matches", + "operation": { + "name": "updateOne", + "arguments": { + "filter": { + "_id": 1 + }, + "update": { + "$inc": { + "x": 1 + } + } } - ], - "tests": [ - { - "description": "UpdateOne when many documents match", - "operation": { - "arguments": { - "filter": { - "_id": { - "$gt": 1 - } - }, - "update": { - "$inc": { - "x": 1 - } - } - }, - "name": "updateOne" - }, - "outcome": { - "result": { - "matchedCount": 1, - "modifiedCount": 1 - } + }, + "outcome": { + "result": { + "matchedCount": 1, + "modifiedCount": 1, + "upsertedCount": 0 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 12 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 } - }, - { - "description": "UpdateOne when one document matches", - "operation": { - "arguments": { - "filter": { - "_id": 1 - }, - "update": { - "$inc": { - "x": 1 - } - } - }, - "name": "updateOne" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 12 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "matchedCount": 1, - "modifiedCount": 1 - } + ] + } + } + }, + { + "description": "UpdateOne when no documents match", + "operation": { + "name": "updateOne", + "arguments": { + "filter": { + "_id": 4 + }, + "update": { + "$inc": { + "x": 1 } - }, - { - "description": "UpdateOne when no documents match", - "operation": { - "arguments": { - "filter": { - "_id": 4 - }, - "update": { - "$inc": { - "x": 1 - } - } - }, - "name": "updateOne" - }, - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": 2, - "x": 22 - }, - { - "_id": 3, - "x": 33 - } - ] - }, - "result": { - "matchedCount": 0, - "modifiedCount": 0 - } + } + } + }, + "outcome": { + "result": { + "matchedCount": 0, + "modifiedCount": 0, + "upsertedCount": 0 + }, + "collection": { + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 } - }, - { - "description": "UpdateOne with upsert when no documents match", - "operation": { - "arguments": { - "filter": { - "_id": 4 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "upsert": true - }, - "name": "updateOne" - }, - "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": "UpdateOne with upsert when no documents match", + "operation": { + "name": "updateOne", + "arguments": { + "filter": { + "_id": 4 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "upsert": true + } + }, + "outcome": { + "result": { + "matchedCount": 0, + "modifiedCount": 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 diff --git a/source/crud/tests/write/updateOne.yml b/source/crud/tests/write/updateOne.yml index 168a6d0c3a..223532feac 100644 --- a/source/crud/tests/write/updateOne.yml +++ b/source/crud/tests/write/updateOne.yml @@ -2,6 +2,7 @@ data: - {_id: 1, x: 11} - {_id: 2, x: 22} - {_id: 3, x: 33} +minServerVersion: '2.6' tests: - @@ -18,8 +19,9 @@ tests: result: matchedCount: 1 modifiedCount: 1 - # can't verify collection because we don't have a way - # of knowing which document gets updated. + upsertedCount: 0 + # Can't verify collection data because we don't have a way of + # knowing which document gets updated. - description: "UpdateOne when one document matches" operation: @@ -33,6 +35,7 @@ tests: result: matchedCount: 1 modifiedCount: 1 + upsertedCount: 0 collection: data: - {_id: 1, x: 12} @@ -51,6 +54,7 @@ tests: result: matchedCount: 0 modifiedCount: 0 + upsertedCount: 0 collection: data: - {_id: 1, x: 11} @@ -70,6 +74,7 @@ tests: result: matchedCount: 0 modifiedCount: 0 + upsertedCount: 1 upsertedId: 4 collection: data: