From f806b5ca6ddaf671df753de9ac48c66f5d03b550 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Tue, 15 Feb 2022 14:58:34 -0500 Subject: [PATCH 01/11] Add new crud spec tests --- test/spec/crud/unified/deleteMany-let.json | 199 +++++++++++++++ test/spec/crud/unified/deleteMany-let.yml | 91 +++++++ test/spec/crud/unified/deleteOne-let.json | 189 ++++++++++++++ test/spec/crud/unified/deleteOne-let.yml | 89 +++++++ test/spec/crud/unified/find-let.json | 148 +++++++++++ test/spec/crud/unified/find-let.yml | 71 ++++++ .../crud/unified/findOneAndDelete-let.json | 180 +++++++++++++ .../crud/unified/findOneAndDelete-let.yml | 87 +++++++ .../crud/unified/findOneAndReplace-let.json | 197 ++++++++++++++ .../crud/unified/findOneAndReplace-let.yml | 94 +++++++ .../crud/unified/findOneAndUpdate-let-yml | 96 +++++++ .../crud/unified/findOneAndUpdate-let.json | 217 ++++++++++++++++ test/spec/crud/unified/updateMany-let.json | 241 ++++++++++++++++++ test/spec/crud/unified/updateMany-let.yml | 103 ++++++++ test/spec/crud/unified/updateOne-let.json | 215 ++++++++++++++++ test/spec/crud/unified/updateOne-let.yml | 98 +++++++ 16 files changed, 2315 insertions(+) create mode 100644 test/spec/crud/unified/deleteMany-let.json create mode 100644 test/spec/crud/unified/deleteMany-let.yml create mode 100644 test/spec/crud/unified/deleteOne-let.json create mode 100644 test/spec/crud/unified/deleteOne-let.yml create mode 100644 test/spec/crud/unified/find-let.json create mode 100644 test/spec/crud/unified/find-let.yml create mode 100644 test/spec/crud/unified/findOneAndDelete-let.json create mode 100644 test/spec/crud/unified/findOneAndDelete-let.yml create mode 100644 test/spec/crud/unified/findOneAndReplace-let.json create mode 100644 test/spec/crud/unified/findOneAndReplace-let.yml create mode 100644 test/spec/crud/unified/findOneAndUpdate-let-yml create mode 100644 test/spec/crud/unified/findOneAndUpdate-let.json create mode 100644 test/spec/crud/unified/updateMany-let.json create mode 100644 test/spec/crud/unified/updateMany-let.yml create mode 100644 test/spec/crud/unified/updateOne-let.json create mode 100644 test/spec/crud/unified/updateOne-let.yml diff --git a/test/spec/crud/unified/deleteMany-let.json b/test/spec/crud/unified/deleteMany-let.json new file mode 100644 index 00000000000..18ef2864193 --- /dev/null +++ b/test/spec/crud/unified/deleteMany-let.json @@ -0,0 +1,199 @@ +{ + "description": "deleteMany-let", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2, + "name": "name" + }, + { + "_id": 3, + "name": "name" + } + ] + } + ], + "tests": [ + { + "description": "deleteMany with let option", + "runOnRequirements": [ + { + "minServerVersion": "5.0" + } + ], + "operations": [ + { + "name": "deleteMany", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$name", + "$$name" + ] + } + }, + "let": { + "name": "name" + } + }, + "expectResult": { + "deletedCount": 2 + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "coll0", + "deletes": [ + { + "q": { + "$expr": { + "$eq": [ + "$name", + "$$name" + ] + } + } + } + ], + "let": { + "name": "name" + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "deleteMany with let option unsupported (server-side error)", + "runOnRequirements": [ + { + "minServerVersion": "3.6.0", + "maxServerVersion": "4.4.99" + } + ], + "operations": [ + { + "name": "deleteMany", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$name", + "$$name" + ] + } + }, + "let": { + "name": "name" + } + }, + "expectError": { + "errorContains": "'delete.let' is an unknown field", + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "coll0", + "deletes": [ + { + "q": { + "$expr": { + "$eq": [ + "$name", + "$$name" + ] + } + } + } + ], + "let": { + "name": "name" + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2, + "name": "name" + }, + { + "_id": 3, + "name": "name" + } + ] + } + ] + } + ] +} diff --git a/test/spec/crud/unified/deleteMany-let.yml b/test/spec/crud/unified/deleteMany-let.yml new file mode 100644 index 00000000000..72f4d402e64 --- /dev/null +++ b/test/spec/crud/unified/deleteMany-let.yml @@ -0,0 +1,91 @@ +description: "deleteMany-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2, name: "name" } + - { _id: 3, name: "name" } + +tests: + - description: "deleteMany with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: deleteMany + object: *collection0 + arguments: + filter: &filter + $expr: + $eq: [ "$name", "$$name" ] + let: &let0 + name: "name" + expectResult: + deletedCount: 2 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - + q: *filter + let: *let0 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + + - description: "deleteMany with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "3.6.0" + maxServerVersion: "4.4.99" + operations: + - name: deleteMany + object: *collection0 + arguments: + filter: &filter1 + $expr: + $eq: [ "$name", "$$name" ] + let: &let1 + name: "name" + expectError: + errorContains: "'delete.let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - + q: *filter1 + let: *let1 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2, name: "name" } + - { _id: 3, name: "name" } diff --git a/test/spec/crud/unified/deleteOne-let.json b/test/spec/crud/unified/deleteOne-let.json new file mode 100644 index 00000000000..ba3872c56c7 --- /dev/null +++ b/test/spec/crud/unified/deleteOne-let.json @@ -0,0 +1,189 @@ +{ + "description": "deleteOne-let", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "deleteOne with let option", + "runOnRequirements": [ + { + "minServerVersion": "5.0" + } + ], + "operations": [ + { + "name": "deleteOne", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "let": { + "id": 1 + } + }, + "expectResult": { + "deletedCount": 1 + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "coll0", + "deletes": [ + { + "q": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + } + } + ], + "let": { + "id": 1 + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 2 + } + ] + } + ] + }, + { + "description": "deleteOne with let option unsupported (server-side error)", + "runOnRequirements": [ + { + "minServerVersion": "3.6.0", + "maxServerVersion": "4.4.99" + } + ], + "operations": [ + { + "name": "deleteOne", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "let": { + "id": 1 + } + }, + "expectError": { + "errorContains": "'delete.let' is an unknown field", + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "coll0", + "deletes": [ + { + "q": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + } + } + ], + "let": { + "id": 1 + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ] + } + ] +} diff --git a/test/spec/crud/unified/deleteOne-let.yml b/test/spec/crud/unified/deleteOne-let.yml new file mode 100644 index 00000000000..c07ec9c5ba2 --- /dev/null +++ b/test/spec/crud/unified/deleteOne-let.yml @@ -0,0 +1,89 @@ +description: "deleteOne-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + +tests: + - description: "deleteOne with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: deleteOne + object: *collection0 + arguments: + filter: &filter + $expr: + $eq: [ "$_id", "$$id" ] + let: &let0 + id: 1 + expectResult: + deletedCount: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - + q: *filter + let: *let0 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 2 } + + - description: "deleteOne with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "3.6.0" + maxServerVersion: "4.4.99" + operations: + - name: deleteOne + object: *collection0 + arguments: + filter: &filter1 + $expr: + $eq: [ "$_id", "$$id" ] + let: &let1 + id: 1 + expectError: + errorContains: "'delete.let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - + q: *filter1 + let: *let1 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } diff --git a/test/spec/crud/unified/find-let.json b/test/spec/crud/unified/find-let.json new file mode 100644 index 00000000000..752d8ac56c1 --- /dev/null +++ b/test/spec/crud/unified/find-let.json @@ -0,0 +1,148 @@ +{ + "description": "find-let", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "Find with let option", + "runOnRequirements": [ + { + "minServerVersion": "5.0" + } + ], + "operations": [ + { + "name": "find", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "let": { + "id": 1 + } + }, + "expectResult": [ + { + "_id": 1 + } + ] + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "find": "coll0", + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "let": { + "id": 1 + } + } + } + } + ] + } + ] + }, + { + "description": "Find with let option unsupported (server-side error)", + "runOnRequirements": [ + { + "minServerVersion": "3.6.0", + "maxServerVersion": "4.4.99" + } + ], + "operations": [ + { + "name": "find", + "object": "collection0", + "arguments": { + "filter": { + "_id": 1 + }, + "let": { + "x": 1 + } + }, + "expectError": { + "errorContains": "Unrecognized field 'let'", + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "find": "coll0", + "filter": { + "_id": 1 + }, + "let": { + "x": 1 + } + } + } + } + ] + } + ] + } + ] +} diff --git a/test/spec/crud/unified/find-let.yml b/test/spec/crud/unified/find-let.yml new file mode 100644 index 00000000000..20afe85c879 --- /dev/null +++ b/test/spec/crud/unified/find-let.yml @@ -0,0 +1,71 @@ +description: "find-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + +tests: + - description: "Find with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: find + object: *collection0 + arguments: + filter: &filter + $expr: + $eq: [ "$_id", "$$id" ] + let: &let0 + id: 1 + expectResult: + - { _id: 1 } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + let: *let0 + + - description: "Find with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "3.6.0" + maxServerVersion: "4.4.99" + operations: + - name: find + object: *collection0 + arguments: + filter: &filter1 + _id: 1 + let: &let1 + x: 1 + expectError: + errorContains: "Unrecognized field 'let'" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter1 + let: *let1 diff --git a/test/spec/crud/unified/findOneAndDelete-let.json b/test/spec/crud/unified/findOneAndDelete-let.json new file mode 100644 index 00000000000..04107bf8e87 --- /dev/null +++ b/test/spec/crud/unified/findOneAndDelete-let.json @@ -0,0 +1,180 @@ +{ + "description": "findOneAndDelete-let", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "findOneAndDelete with let option", + "runOnRequirements": [ + { + "minServerVersion": "5.0" + } + ], + "operations": [ + { + "name": "findOneAndDelete", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "let": { + "id": 1 + } + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "remove": true, + "let": { + "id": 1 + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 2 + } + ] + } + ] + }, + { + "description": "findOneAndDelete with let option unsupported (server-side error)", + "runOnRequirements": [ + { + "minServerVersion": "4.2.0", + "maxServerVersion": "4.4.99" + } + ], + "operations": [ + { + "name": "findOneAndDelete", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "let": { + "id": 1 + } + }, + "expectError": { + "errorContains": "field 'let' is an unknown field", + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "remove": true, + "let": { + "id": 1 + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ] + } + ] +} diff --git a/test/spec/crud/unified/findOneAndDelete-let.yml b/test/spec/crud/unified/findOneAndDelete-let.yml new file mode 100644 index 00000000000..1611724ecbf --- /dev/null +++ b/test/spec/crud/unified/findOneAndDelete-let.yml @@ -0,0 +1,87 @@ +description: "findOneAndDelete-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + +tests: + - description: "findOneAndDelete with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: findOneAndDelete + object: *collection0 + arguments: + filter: &filter + $expr: + $eq: [ "$_id", "$$id" ] + let: &let0 + id: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter + remove: true + let: *let0 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 2 } + + - description: "findOneAndDelete with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "4.2.0" + maxServerVersion: "4.4.99" + operations: + - name: findOneAndDelete + object: *collection0 + arguments: + filter: &filter1 + $expr: + $eq: [ "$_id", "$$id" ] + let: &let1 + id: 1 + expectError: + # This error message is consistent between 4.2.x and 4.4.x servers. + # Older servers return a different error message. + errorContains: "field 'let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter1 + remove: true + let: *let1 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } diff --git a/test/spec/crud/unified/findOneAndReplace-let.json b/test/spec/crud/unified/findOneAndReplace-let.json new file mode 100644 index 00000000000..e407f9b746c --- /dev/null +++ b/test/spec/crud/unified/findOneAndReplace-let.json @@ -0,0 +1,197 @@ +{ + "description": "findOneAndReplace-let", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "findOneAndReplace with let option", + "runOnRequirements": [ + { + "minServerVersion": "5.0" + } + ], + "operations": [ + { + "name": "findOneAndReplace", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "replacement": { + "x": "x" + }, + "let": { + "id": 1 + } + }, + "expectResult": { + "_id": 1 + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "update": { + "x": "x" + }, + "let": { + "id": 1 + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": "x" + }, + { + "_id": 2 + } + ] + } + ] + }, + { + "description": "findOneAndReplace with let option unsupported (server-side error)", + "runOnRequirements": [ + { + "minServerVersion": "4.2.0", + "maxServerVersion": "4.4.99" + } + ], + "operations": [ + { + "name": "findOneAndReplace", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "replacement": { + "x": "x" + }, + "let": { + "id": 1 + } + }, + "expectError": { + "errorContains": "field 'let' is an unknown field", + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "update": { + "x": "x" + }, + "let": { + "id": 1 + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ] + } + ] +} diff --git a/test/spec/crud/unified/findOneAndReplace-let.yml b/test/spec/crud/unified/findOneAndReplace-let.yml new file mode 100644 index 00000000000..3ee1b7b672f --- /dev/null +++ b/test/spec/crud/unified/findOneAndReplace-let.yml @@ -0,0 +1,94 @@ +description: "findOneAndReplace-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + +tests: + - description: "findOneAndReplace with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: findOneAndReplace + object: *collection0 + arguments: + filter: &filter + $expr: + $eq: [ "$_id", "$$id" ] + replacement: &replacement + x: "x" + let: &let0 + id: 1 + expectResult: + _id: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter + update: *replacement + let: *let0 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: "x" } + - { _id: 2 } + + - description: "findOneAndReplace with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "4.2.0" + maxServerVersion: "4.4.99" + operations: + - name: findOneAndReplace + object: *collection0 + arguments: + filter: &filter1 + $expr: + $eq: [ "$_id", "$$id" ] + replacement: &replacement1 + x: "x" + let: &let1 + id: 1 + expectError: + # This error message is consistent between 4.2.x and 4.4.x servers. + # Older servers return a different error message. + errorContains: "field 'let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter1 + update: *replacement1 + let: *let1 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } diff --git a/test/spec/crud/unified/findOneAndUpdate-let-yml b/test/spec/crud/unified/findOneAndUpdate-let-yml new file mode 100644 index 00000000000..761001db9ef --- /dev/null +++ b/test/spec/crud/unified/findOneAndUpdate-let-yml @@ -0,0 +1,96 @@ +description: "findOneAndUpdate-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + +tests: + - description: "findOneAndUpdate with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: findOneAndUpdate + object: *collection0 + arguments: + filter: &filter + $expr: + $eq: [ "$_id", "$$id" ] + update: &update + - $set: {x: "$$x" } + let: &let0 + id: 1 + x: "foo" + expectResult: + _id: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter + update: *update + let: *let0 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: "foo" } + - { _id: 2 } + + - description: "findOneAndUpdate with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "4.2.0" + maxServerVersion: "4.4.99" + operations: + - name: findOneAndUpdate + object: *collection0 + arguments: + filter: &filter1 + $expr: + $eq: [ "$_id", "$$id" ] + update: &update1 + - $set: {x: "$$x"} + let: &let1 + id: 1 + x: "foo" + expectError: + # This error message is consistent between 4.2.x and 4.4.x servers. + # Older servers return a different error message. + errorContains: "field 'let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter1 + update: *update1 + let: *let1 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } diff --git a/test/spec/crud/unified/findOneAndUpdate-let.json b/test/spec/crud/unified/findOneAndUpdate-let.json new file mode 100644 index 00000000000..401e9fea83d --- /dev/null +++ b/test/spec/crud/unified/findOneAndUpdate-let.json @@ -0,0 +1,217 @@ +{ + "description": "findOneAndUpdate-let", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "findOneAndUpdate with let option", + "runOnRequirements": [ + { + "minServerVersion": "5.0" + } + ], + "operations": [ + { + "name": "findOneAndUpdate", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "update": [ + { + "$set": { + "x": "$$x" + } + } + ], + "let": { + "id": 1, + "x": "foo" + } + }, + "expectResult": { + "_id": 1 + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "update": [ + { + "$set": { + "x": "$$x" + } + } + ], + "let": { + "id": 1, + "x": "foo" + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": "foo" + }, + { + "_id": 2 + } + ] + } + ] + }, + { + "description": "findOneAndUpdate with let option unsupported (server-side error)", + "runOnRequirements": [ + { + "minServerVersion": "4.2.0", + "maxServerVersion": "4.4.99" + } + ], + "operations": [ + { + "name": "findOneAndUpdate", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "update": [ + { + "$set": { + "x": "$$x" + } + } + ], + "let": { + "id": 1, + "x": "foo" + } + }, + "expectError": { + "errorContains": "field 'let' is an unknown field", + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "update": [ + { + "$set": { + "x": "$$x" + } + } + ], + "let": { + "id": 1, + "x": "foo" + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ] + } + ] +} diff --git a/test/spec/crud/unified/updateMany-let.json b/test/spec/crud/unified/updateMany-let.json new file mode 100644 index 00000000000..28856bccb97 --- /dev/null +++ b/test/spec/crud/unified/updateMany-let.json @@ -0,0 +1,241 @@ +{ + "description": "updateMany-let", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2, + "name": "name" + }, + { + "_id": 3, + "name": "name" + } + ] + } + ], + "tests": [ + { + "description": "updateMany with let option", + "runOnRequirements": [ + { + "minServerVersion": "5.0" + } + ], + "operations": [ + { + "name": "updateMany", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$name", + "$$name" + ] + } + }, + "update": [ + { + "$set": { + "x": "$$x", + "y": "$$y" + } + } + ], + "let": { + "name": "name", + "x": "foo", + "y": { + "$literal": "bar" + } + } + }, + "expectResult": { + "matchedCount": 2, + "modifiedCount": 2, + "upsertedCount": 0 + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": { + "$expr": { + "$eq": [ + "$name", + "$$name" + ] + } + }, + "u": [ + { + "$set": { + "x": "$$x", + "y": "$$y" + } + } + ] + } + ], + "let": { + "name": "name", + "x": "foo", + "y": { + "$literal": "bar" + } + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2, + "name": "name", + "x": "foo", + "y": "bar" + }, + { + "_id": 3, + "name": "name", + "x": "foo", + "y": "bar" + } + ] + } + ] + }, + { + "description": "updateMany with let option unsupported (server-side error)", + "runOnRequirements": [ + { + "minServerVersion": "3.6.0", + "maxServerVersion": "4.4.99" + } + ], + "operations": [ + { + "name": "updateMany", + "object": "collection0", + "arguments": { + "filter": { + "_id": 1 + }, + "update": [ + { + "$set": { + "x": "$$x" + } + } + ], + "let": { + "x": "foo" + } + }, + "expectError": { + "errorContains": "'update.let' is an unknown field", + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": { + "_id": 1 + }, + "u": [ + { + "$set": { + "x": "$$x" + } + } + ] + } + ], + "let": { + "x": "foo" + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2, + "name": "name" + }, + { + "_id": 3, + "name": "name" + } + ] + } + ] + } + ] +} diff --git a/test/spec/crud/unified/updateMany-let.yml b/test/spec/crud/unified/updateMany-let.yml new file mode 100644 index 00000000000..f0d8842df8f --- /dev/null +++ b/test/spec/crud/unified/updateMany-let.yml @@ -0,0 +1,103 @@ +description: "updateMany-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2, name: "name" } + - { _id: 3, name: "name" } + + +tests: + - description: "updateMany with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: updateMany + object: *collection0 + arguments: + filter: &filter + $expr: + $eq: [ "$name", "$$name" ] + update: &update + - $set: {x: "$$x", y: "$$y" } + let: &let0 + name: name + x: foo + y: { $literal: "bar" } + expectResult: + matchedCount: 2 + modifiedCount: 2 + upsertedCount: 0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - + q: *filter + u: *update + let: *let0 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2, name: "name", x: "foo", y: "bar" } + - { _id: 3, name: "name", x: "foo", y: "bar" } + + - description: "updateMany with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "3.6.0" + maxServerVersion: "4.4.99" + operations: + - name: updateMany + object: *collection0 + arguments: + filter: &filter1 + _id: 1 + update: &update1 + - $set: {x: "$$x"} + let: &let1 + x: foo + expectError: + errorContains: "'update.let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - + q: *filter1 + u: *update1 + let: *let1 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2, name: "name" } + - { _id: 3, name: "name" } diff --git a/test/spec/crud/unified/updateOne-let.json b/test/spec/crud/unified/updateOne-let.json new file mode 100644 index 00000000000..98f96d1d2f0 --- /dev/null +++ b/test/spec/crud/unified/updateOne-let.json @@ -0,0 +1,215 @@ +{ + "description": "updateOne-let", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "UpdateOne with let option", + "runOnRequirements": [ + { + "minServerVersion": "5.0" + } + ], + "operations": [ + { + "name": "updateOne", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "update": [ + { + "$set": { + "x": "$$x" + } + } + ], + "let": { + "id": 1, + "x": "foo" + } + }, + "expectResult": { + "matchedCount": 1, + "modifiedCount": 1, + "upsertedCount": 0 + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "u": [ + { + "$set": { + "x": "$$x" + } + } + ] + } + ], + "let": { + "id": 1, + "x": "foo" + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": "foo" + }, + { + "_id": 2 + } + ] + } + ] + }, + { + "description": "UpdateOne with let option unsupported (server-side error)", + "runOnRequirements": [ + { + "minServerVersion": "3.6.0", + "maxServerVersion": "4.4.99" + } + ], + "operations": [ + { + "name": "updateOne", + "object": "collection0", + "arguments": { + "filter": { + "_id": 1 + }, + "update": [ + { + "$set": { + "x": "$$x" + } + } + ], + "let": { + "x": "foo" + } + }, + "expectError": { + "errorContains": "'update.let' is an unknown field", + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": { + "_id": 1 + }, + "u": [ + { + "$set": { + "x": "$$x" + } + } + ] + } + ], + "let": { + "x": "foo" + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ] + } + ] +} diff --git a/test/spec/crud/unified/updateOne-let.yml b/test/spec/crud/unified/updateOne-let.yml new file mode 100644 index 00000000000..0795cfb9be3 --- /dev/null +++ b/test/spec/crud/unified/updateOne-let.yml @@ -0,0 +1,98 @@ +description: "updateOne-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + +tests: + - description: "UpdateOne with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: updateOne + object: *collection0 + arguments: + filter: &filter + $expr: + $eq: [ "$_id", "$$id" ] + update: &update + - $set: {x: "$$x" } + let: &let0 + id: 1 + x: "foo" + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - + q: *filter + u: *update + let: *let0 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: "foo" } + - { _id: 2 } + + - description: "UpdateOne with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "3.6.0" + maxServerVersion: "4.4.99" + operations: + - name: updateOne + object: *collection0 + arguments: + filter: &filter1 + _id: 1 + update: &update1 + - $set: {x: "$$x"} + let: &let1 + x: foo + expectError: + errorContains: "'update.let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - + q: *filter1 + u: *update1 + let: *let1 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } From 9424ead5196ebc3d48563e7427a7bf5ab43d3d16 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Tue, 15 Feb 2022 15:41:43 -0500 Subject: [PATCH 02/11] pull in let test fixes --- test/spec/crud/unified/deleteMany-let.json | 6 ++++-- test/spec/crud/unified/deleteMany-let.yml | 2 ++ test/spec/crud/unified/deleteOne-let.json | 6 ++++-- test/spec/crud/unified/deleteOne-let.yml | 2 ++ test/spec/crud/unified/updateMany-let.json | 6 ++++-- test/spec/crud/unified/updateMany-let.yml | 2 ++ 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/test/spec/crud/unified/deleteMany-let.json b/test/spec/crud/unified/deleteMany-let.json index 18ef2864193..3d959f7eb7b 100644 --- a/test/spec/crud/unified/deleteMany-let.json +++ b/test/spec/crud/unified/deleteMany-let.json @@ -91,7 +91,8 @@ "$$name" ] } - } + }, + "limit": 0 } ], "let": { @@ -163,7 +164,8 @@ "$$name" ] } - } + }, + "limit": 0 } ], "let": { diff --git a/test/spec/crud/unified/deleteMany-let.yml b/test/spec/crud/unified/deleteMany-let.yml index 72f4d402e64..723985aa8c0 100644 --- a/test/spec/crud/unified/deleteMany-let.yml +++ b/test/spec/crud/unified/deleteMany-let.yml @@ -47,6 +47,7 @@ tests: deletes: - q: *filter + limit: 0 let: *let0 outcome: - @@ -80,6 +81,7 @@ tests: deletes: - q: *filter1 + limit: 0 let: *let1 outcome: - diff --git a/test/spec/crud/unified/deleteOne-let.json b/test/spec/crud/unified/deleteOne-let.json index ba3872c56c7..7b7695c2739 100644 --- a/test/spec/crud/unified/deleteOne-let.json +++ b/test/spec/crud/unified/deleteOne-let.json @@ -86,7 +86,8 @@ "$$id" ] } - } + }, + "limit": 1 } ], "let": { @@ -158,7 +159,8 @@ "$$id" ] } - } + }, + "limit": 1 } ], "let": { diff --git a/test/spec/crud/unified/deleteOne-let.yml b/test/spec/crud/unified/deleteOne-let.yml index c07ec9c5ba2..c52d98b99d4 100644 --- a/test/spec/crud/unified/deleteOne-let.yml +++ b/test/spec/crud/unified/deleteOne-let.yml @@ -46,6 +46,7 @@ tests: deletes: - q: *filter + limit: 1 let: *let0 outcome: - @@ -79,6 +80,7 @@ tests: deletes: - q: *filter1 + limit: 1 let: *let1 outcome: - diff --git a/test/spec/crud/unified/updateMany-let.json b/test/spec/crud/unified/updateMany-let.json index 28856bccb97..374d0a8670b 100644 --- a/test/spec/crud/unified/updateMany-let.json +++ b/test/spec/crud/unified/updateMany-let.json @@ -113,7 +113,8 @@ "y": "$$y" } } - ] + ], + "multi": true } ], "let": { @@ -205,7 +206,8 @@ "x": "$$x" } } - ] + ], + "multi": true } ], "let": { diff --git a/test/spec/crud/unified/updateMany-let.yml b/test/spec/crud/unified/updateMany-let.yml index f0d8842df8f..670fe4f7081 100644 --- a/test/spec/crud/unified/updateMany-let.yml +++ b/test/spec/crud/unified/updateMany-let.yml @@ -55,6 +55,7 @@ tests: - q: *filter u: *update + multi: true let: *let0 outcome: - @@ -92,6 +93,7 @@ tests: - q: *filter1 u: *update1 + multi: true let: *let1 outcome: - From 47c79cb4aa6c78c812e42a109499249a32a5feb7 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Tue, 15 Feb 2022 15:52:49 -0500 Subject: [PATCH 03/11] Add aggregate-let tests --- test/spec/crud/unified/aggregate-let.json | 103 ---------------------- test/spec/crud/unified/aggregate-let.yml | 36 -------- 2 files changed, 139 deletions(-) diff --git a/test/spec/crud/unified/aggregate-let.json b/test/spec/crud/unified/aggregate-let.json index d3b76bd65a1..039900920fb 100644 --- a/test/spec/crud/unified/aggregate-let.json +++ b/test/spec/crud/unified/aggregate-let.json @@ -56,109 +56,6 @@ "minServerVersion": "5.0" } ], - "operations": [ - { - "name": "aggregate", - "object": "collection0", - "arguments": { - "pipeline": [ - { - "$match": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - } - }, - { - "$project": { - "_id": 0, - "x": "$$x", - "y": "$$y", - "rand": "$$rand" - } - } - ], - "let": { - "id": 1, - "x": "foo", - "y": { - "$literal": "bar" - }, - "rand": { - "$rand": {} - } - } - }, - "expectResult": [ - { - "x": "foo", - "y": "bar", - "rand": { - "$$type": "double" - } - } - ] - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "coll0", - "pipeline": [ - { - "$match": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - } - }, - { - "$project": { - "_id": 0, - "x": "$$x", - "y": "$$y", - "rand": "$$rand" - } - } - ], - "let": { - "id": 1, - "x": "foo", - "y": { - "$literal": "bar" - }, - "rand": { - "$rand": {} - } - } - } - } - } - ] - } - ] - }, - { - "description": "Aggregate with let option and dollar-prefixed $literal value", - "runOnRequirements": [ - { - "minServerVersion": "5.0", - "topologies": [ - "single", - "replicaset" - ] - } - ], "operations": [ { "name": "aggregate", diff --git a/test/spec/crud/unified/aggregate-let.yml b/test/spec/crud/unified/aggregate-let.yml index 80da3d90b3c..7fa1f9b798e 100644 --- a/test/spec/crud/unified/aggregate-let.yml +++ b/test/spec/crud/unified/aggregate-let.yml @@ -29,45 +29,9 @@ initialData: &initialData documents: [ ] tests: - # TODO: Once SERVER-57403 is resolved, this test can be removed in favor of - # the "dollar-prefixed $literal value" test below. - description: "Aggregate with let option" runOnRequirements: - minServerVersion: "5.0" - operations: - - name: aggregate - object: *collection0 - arguments: - pipeline: &pipeline0 - # $match takes a query expression, so $expr is necessary to utilize - # an aggregate expression context and access "let" variables. - - $match: { $expr: { $eq: ["$_id", "$$id"] } } - - $project: { _id: 0, x: "$$x", y: "$$y", rand: "$$rand" } - # Values in "let" must be constant or closed expressions that do not - # depend on document values. This test demonstrates a basic constant - # value, a value wrapped with $literal (to avoid expression parsing), - # and a closed expression (e.g. $rand). - let: &let0 - id: 1 - x: foo - y: { $literal: "bar" } - rand: { $rand: {} } - expectResult: - - { x: "foo", y: "bar", rand: { $$type: "double" } } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: *pipeline0 - let: *let0 - - - description: "Aggregate with let option and dollar-prefixed $literal value" - runOnRequirements: - - minServerVersion: "5.0" - # TODO: Remove topology restrictions once SERVER-57403 is resolved - topologies: ["single", "replicaset"] operations: - name: aggregate object: *collection0 From 3569392c1a0f2a0dde9bd1566e3643db7bd52d90 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Tue, 15 Feb 2022 16:20:19 -0500 Subject: [PATCH 04/11] Rename findOneAndUpdate-let-yml -> findOneAndUpdate-let.yml --- .../{findOneAndUpdate-let-yml => findOneAndUpdate-let.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/spec/crud/unified/{findOneAndUpdate-let-yml => findOneAndUpdate-let.yml} (100%) diff --git a/test/spec/crud/unified/findOneAndUpdate-let-yml b/test/spec/crud/unified/findOneAndUpdate-let.yml similarity index 100% rename from test/spec/crud/unified/findOneAndUpdate-let-yml rename to test/spec/crud/unified/findOneAndUpdate-let.yml From 2b9abefc83887e3901d28632eed93b46bd282bc0 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Wed, 16 Feb 2022 11:08:03 -0500 Subject: [PATCH 05/11] Fix structure of updateX tests --- test/spec/crud/unified/updateMany-let.json | 34 +++++++++------------- test/spec/crud/unified/updateMany-let.yml | 4 +-- test/spec/crud/unified/updateOne-let.json | 30 ++++++++----------- test/spec/crud/unified/updateOne-let.yml | 4 +-- 4 files changed, 30 insertions(+), 42 deletions(-) diff --git a/test/spec/crud/unified/updateMany-let.json b/test/spec/crud/unified/updateMany-let.json index 374d0a8670b..2b02bb034a8 100644 --- a/test/spec/crud/unified/updateMany-let.json +++ b/test/spec/crud/unified/updateMany-let.json @@ -65,14 +65,12 @@ ] } }, - "update": [ - { - "$set": { - "x": "$$x", - "y": "$$y" - } + "update": { + "$set": { + "x": "$$x", + "y": "$$y" } - ], + }, "let": { "name": "name", "x": "foo", @@ -106,14 +104,12 @@ ] } }, - "u": [ - { - "$set": { - "x": "$$x", - "y": "$$y" - } + "u": { + "$set": { + "x": "$$x", + "y": "$$y" } - ], + }, "multi": true } ], @@ -170,13 +166,11 @@ "filter": { "_id": 1 }, - "update": [ - { - "$set": { - "x": "$$x" - } + "update": { + "$set": { + "x": "$$x" } - ], + }, "let": { "x": "foo" } diff --git a/test/spec/crud/unified/updateMany-let.yml b/test/spec/crud/unified/updateMany-let.yml index 670fe4f7081..77690557847 100644 --- a/test/spec/crud/unified/updateMany-let.yml +++ b/test/spec/crud/unified/updateMany-let.yml @@ -36,7 +36,7 @@ tests: $expr: $eq: [ "$name", "$$name" ] update: &update - - $set: {x: "$$x", y: "$$y" } + $set: {x: "$$x", y: "$$y" } let: &let0 name: name x: foo @@ -77,7 +77,7 @@ tests: filter: &filter1 _id: 1 update: &update1 - - $set: {x: "$$x"} + $set: {x: "$$x"} let: &let1 x: foo expectError: diff --git a/test/spec/crud/unified/updateOne-let.json b/test/spec/crud/unified/updateOne-let.json index 98f96d1d2f0..cbb19861c86 100644 --- a/test/spec/crud/unified/updateOne-let.json +++ b/test/spec/crud/unified/updateOne-let.json @@ -60,13 +60,11 @@ ] } }, - "update": [ - { - "$set": { - "x": "$$x" - } + "update": { + "$set": { + "x": "$$x" } - ], + }, "let": { "id": 1, "x": "foo" @@ -148,13 +146,11 @@ "filter": { "_id": 1 }, - "update": [ - { - "$set": { - "x": "$$x" - } + "update": { + "$set": { + "x": "$$x" } - ], + }, "let": { "x": "foo" } @@ -178,13 +174,11 @@ "q": { "_id": 1 }, - "u": [ - { - "$set": { - "x": "$$x" - } + "u": { + "$set": { + "x": "$$x" } - ] + } } ], "let": { diff --git a/test/spec/crud/unified/updateOne-let.yml b/test/spec/crud/unified/updateOne-let.yml index 0795cfb9be3..eceab5ea396 100644 --- a/test/spec/crud/unified/updateOne-let.yml +++ b/test/spec/crud/unified/updateOne-let.yml @@ -34,7 +34,7 @@ tests: $expr: $eq: [ "$_id", "$$id" ] update: &update - - $set: {x: "$$x" } + $set: {x: "$$x" } let: &let0 id: 1 x: "foo" @@ -72,7 +72,7 @@ tests: filter: &filter1 _id: 1 update: &update1 - - $set: {x: "$$x"} + $set: {x: "$$x"} let: &let1 x: foo expectError: From 97d4aebbf485818a752bf63cbc2995a2d4db0a3f Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Wed, 16 Feb 2022 11:20:25 -0500 Subject: [PATCH 06/11] revert changes to 5.0 tests --- test/spec/crud/unified/updateMany-let.json | 12 +++++++----- test/spec/crud/unified/updateOne-let.json | 10 ++++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/test/spec/crud/unified/updateMany-let.json b/test/spec/crud/unified/updateMany-let.json index 2b02bb034a8..8ed2221efcc 100644 --- a/test/spec/crud/unified/updateMany-let.json +++ b/test/spec/crud/unified/updateMany-let.json @@ -65,12 +65,14 @@ ] } }, - "update": { - "$set": { - "x": "$$x", - "y": "$$y" + "update": [ + { + "$set": { + "x": "$$x", + "y": "$$y" + } } - }, + ], "let": { "name": "name", "x": "foo", diff --git a/test/spec/crud/unified/updateOne-let.json b/test/spec/crud/unified/updateOne-let.json index cbb19861c86..1d63930a34e 100644 --- a/test/spec/crud/unified/updateOne-let.json +++ b/test/spec/crud/unified/updateOne-let.json @@ -60,11 +60,13 @@ ] } }, - "update": { - "$set": { - "x": "$$x" + "update": [ + { + "$set": { + "x": "$$x" + } } - }, + ], "let": { "id": 1, "x": "foo" From bae5ee58f1e03ceb1a6554fda0791f67c4b6afda Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Wed, 16 Feb 2022 12:03:46 -0500 Subject: [PATCH 07/11] Revert "revert changes to 5.0 tests" This reverts commit 97d4aebbf485818a752bf63cbc2995a2d4db0a3f. --- test/spec/crud/unified/updateMany-let.json | 12 +++++------- test/spec/crud/unified/updateOne-let.json | 10 ++++------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/test/spec/crud/unified/updateMany-let.json b/test/spec/crud/unified/updateMany-let.json index 8ed2221efcc..2b02bb034a8 100644 --- a/test/spec/crud/unified/updateMany-let.json +++ b/test/spec/crud/unified/updateMany-let.json @@ -65,14 +65,12 @@ ] } }, - "update": [ - { - "$set": { - "x": "$$x", - "y": "$$y" - } + "update": { + "$set": { + "x": "$$x", + "y": "$$y" } - ], + }, "let": { "name": "name", "x": "foo", diff --git a/test/spec/crud/unified/updateOne-let.json b/test/spec/crud/unified/updateOne-let.json index 1d63930a34e..cbb19861c86 100644 --- a/test/spec/crud/unified/updateOne-let.json +++ b/test/spec/crud/unified/updateOne-let.json @@ -60,13 +60,11 @@ ] } }, - "update": [ - { - "$set": { - "x": "$$x" - } + "update": { + "$set": { + "x": "$$x" } - ], + }, "let": { "id": 1, "x": "foo" From f08a4f691475f2bc2379e160c79eb9e8d521ae1c Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Wed, 16 Feb 2022 12:03:54 -0500 Subject: [PATCH 08/11] Revert "Fix structure of updateX tests" This reverts commit 2b9abefc83887e3901d28632eed93b46bd282bc0. --- test/spec/crud/unified/updateMany-let.json | 34 +++++++++++++--------- test/spec/crud/unified/updateMany-let.yml | 4 +-- test/spec/crud/unified/updateOne-let.json | 30 +++++++++++-------- test/spec/crud/unified/updateOne-let.yml | 4 +-- 4 files changed, 42 insertions(+), 30 deletions(-) diff --git a/test/spec/crud/unified/updateMany-let.json b/test/spec/crud/unified/updateMany-let.json index 2b02bb034a8..374d0a8670b 100644 --- a/test/spec/crud/unified/updateMany-let.json +++ b/test/spec/crud/unified/updateMany-let.json @@ -65,12 +65,14 @@ ] } }, - "update": { - "$set": { - "x": "$$x", - "y": "$$y" + "update": [ + { + "$set": { + "x": "$$x", + "y": "$$y" + } } - }, + ], "let": { "name": "name", "x": "foo", @@ -104,12 +106,14 @@ ] } }, - "u": { - "$set": { - "x": "$$x", - "y": "$$y" + "u": [ + { + "$set": { + "x": "$$x", + "y": "$$y" + } } - }, + ], "multi": true } ], @@ -166,11 +170,13 @@ "filter": { "_id": 1 }, - "update": { - "$set": { - "x": "$$x" + "update": [ + { + "$set": { + "x": "$$x" + } } - }, + ], "let": { "x": "foo" } diff --git a/test/spec/crud/unified/updateMany-let.yml b/test/spec/crud/unified/updateMany-let.yml index 77690557847..670fe4f7081 100644 --- a/test/spec/crud/unified/updateMany-let.yml +++ b/test/spec/crud/unified/updateMany-let.yml @@ -36,7 +36,7 @@ tests: $expr: $eq: [ "$name", "$$name" ] update: &update - $set: {x: "$$x", y: "$$y" } + - $set: {x: "$$x", y: "$$y" } let: &let0 name: name x: foo @@ -77,7 +77,7 @@ tests: filter: &filter1 _id: 1 update: &update1 - $set: {x: "$$x"} + - $set: {x: "$$x"} let: &let1 x: foo expectError: diff --git a/test/spec/crud/unified/updateOne-let.json b/test/spec/crud/unified/updateOne-let.json index cbb19861c86..98f96d1d2f0 100644 --- a/test/spec/crud/unified/updateOne-let.json +++ b/test/spec/crud/unified/updateOne-let.json @@ -60,11 +60,13 @@ ] } }, - "update": { - "$set": { - "x": "$$x" + "update": [ + { + "$set": { + "x": "$$x" + } } - }, + ], "let": { "id": 1, "x": "foo" @@ -146,11 +148,13 @@ "filter": { "_id": 1 }, - "update": { - "$set": { - "x": "$$x" + "update": [ + { + "$set": { + "x": "$$x" + } } - }, + ], "let": { "x": "foo" } @@ -174,11 +178,13 @@ "q": { "_id": 1 }, - "u": { - "$set": { - "x": "$$x" + "u": [ + { + "$set": { + "x": "$$x" + } } - } + ] } ], "let": { diff --git a/test/spec/crud/unified/updateOne-let.yml b/test/spec/crud/unified/updateOne-let.yml index eceab5ea396..0795cfb9be3 100644 --- a/test/spec/crud/unified/updateOne-let.yml +++ b/test/spec/crud/unified/updateOne-let.yml @@ -34,7 +34,7 @@ tests: $expr: $eq: [ "$_id", "$$id" ] update: &update - $set: {x: "$$x" } + - $set: {x: "$$x" } let: &let0 id: 1 x: "foo" @@ -72,7 +72,7 @@ tests: filter: &filter1 _id: 1 update: &update1 - $set: {x: "$$x"} + - $set: {x: "$$x"} let: &let1 x: foo expectError: From 57482717643c5e6433ff5c64694115347fa1fa81 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Wed, 16 Feb 2022 12:09:31 -0500 Subject: [PATCH 09/11] Skip failing update + let tests and add todo --- test/integration/crud/crud.spec.test.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/integration/crud/crud.spec.test.js b/test/integration/crud/crud.spec.test.js index ce145c038c5..4249615685c 100644 --- a/test/integration/crud/crud.spec.test.js +++ b/test/integration/crud/crud.spec.test.js @@ -425,6 +425,12 @@ describe('CRUD spec v1', function () { } }); +// TODO(NODE-4013): Unskip failing update with `let` tests when spec tests are updated +const SKIPPED_TESTS = [ + 'updateMany with let option unsupported (server-side error)', + 'UpdateOne with let option unsupported (server-side error)' +]; + describe('CRUD unified', function () { - runUnifiedSuite(loadSpecTests(path.join('crud', 'unified'))); + runUnifiedSuite(loadSpecTests(path.join('crud', 'unified')), SKIPPED_TESTS); }); From 0a6f3c183c494fdb2c704ab93dd327d3c8fd968b Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Wed, 16 Feb 2022 13:07:30 -0500 Subject: [PATCH 10/11] Sync spec changes from https://github.com/mongodb/specifications/pull/1150 --- test/integration/crud/crud.spec.test.js | 8 +------- test/spec/crud/unified/updateMany-let.json | 2 +- test/spec/crud/unified/updateMany-let.yml | 2 +- test/spec/crud/unified/updateOne-let.json | 2 +- test/spec/crud/unified/updateOne-let.yml | 2 +- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/test/integration/crud/crud.spec.test.js b/test/integration/crud/crud.spec.test.js index 4249615685c..ce145c038c5 100644 --- a/test/integration/crud/crud.spec.test.js +++ b/test/integration/crud/crud.spec.test.js @@ -425,12 +425,6 @@ describe('CRUD spec v1', function () { } }); -// TODO(NODE-4013): Unskip failing update with `let` tests when spec tests are updated -const SKIPPED_TESTS = [ - 'updateMany with let option unsupported (server-side error)', - 'UpdateOne with let option unsupported (server-side error)' -]; - describe('CRUD unified', function () { - runUnifiedSuite(loadSpecTests(path.join('crud', 'unified')), SKIPPED_TESTS); + runUnifiedSuite(loadSpecTests(path.join('crud', 'unified'))); }); diff --git a/test/spec/crud/unified/updateMany-let.json b/test/spec/crud/unified/updateMany-let.json index 374d0a8670b..8a48aeb4a45 100644 --- a/test/spec/crud/unified/updateMany-let.json +++ b/test/spec/crud/unified/updateMany-let.json @@ -158,7 +158,7 @@ "description": "updateMany with let option unsupported (server-side error)", "runOnRequirements": [ { - "minServerVersion": "3.6.0", + "minServerVersion": "4.2.0", "maxServerVersion": "4.4.99" } ], diff --git a/test/spec/crud/unified/updateMany-let.yml b/test/spec/crud/unified/updateMany-let.yml index 670fe4f7081..6551bfbc56f 100644 --- a/test/spec/crud/unified/updateMany-let.yml +++ b/test/spec/crud/unified/updateMany-let.yml @@ -68,7 +68,7 @@ tests: - description: "updateMany with let option unsupported (server-side error)" runOnRequirements: - - minServerVersion: "3.6.0" + - minServerVersion: "4.2.0" maxServerVersion: "4.4.99" operations: - name: updateMany diff --git a/test/spec/crud/unified/updateOne-let.json b/test/spec/crud/unified/updateOne-let.json index 98f96d1d2f0..001da55505e 100644 --- a/test/spec/crud/unified/updateOne-let.json +++ b/test/spec/crud/unified/updateOne-let.json @@ -136,7 +136,7 @@ "description": "UpdateOne with let option unsupported (server-side error)", "runOnRequirements": [ { - "minServerVersion": "3.6.0", + "minServerVersion": "4.2.0", "maxServerVersion": "4.4.99" } ], diff --git a/test/spec/crud/unified/updateOne-let.yml b/test/spec/crud/unified/updateOne-let.yml index 0795cfb9be3..63f8bbdae8e 100644 --- a/test/spec/crud/unified/updateOne-let.yml +++ b/test/spec/crud/unified/updateOne-let.yml @@ -63,7 +63,7 @@ tests: - description: "UpdateOne with let option unsupported (server-side error)" runOnRequirements: - - minServerVersion: "3.6.0" + - minServerVersion: "4.2.0" maxServerVersion: "4.4.99" operations: - name: updateOne From 5c01ff12d4178d6ceb614e32c29c59c710354655 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Fri, 18 Feb 2022 11:32:16 -0500 Subject: [PATCH 11/11] reformat json files --- test/spec/crud/unified/deleteMany-let.json | 364 +++++++-------- test/spec/crud/unified/deleteOne-let.json | 346 +++++++------- test/spec/crud/unified/find-let.json | 266 +++++------ .../crud/unified/findOneAndDelete-let.json | 326 ++++++------- .../crud/unified/findOneAndReplace-let.json | 360 +++++++------- .../crud/unified/findOneAndUpdate-let.json | 396 ++++++++-------- test/spec/crud/unified/updateMany-let.json | 438 +++++++++--------- test/spec/crud/unified/updateOne-let.json | 386 +++++++-------- 8 files changed, 1441 insertions(+), 1441 deletions(-) diff --git a/test/spec/crud/unified/deleteMany-let.json b/test/spec/crud/unified/deleteMany-let.json index 3d959f7eb7b..71bf26a013f 100644 --- a/test/spec/crud/unified/deleteMany-let.json +++ b/test/spec/crud/unified/deleteMany-let.json @@ -1,201 +1,201 @@ { - "description": "deleteMany-let", - "schemaVersion": "1.0", - "createEntities": [ + "description": "deleteMany-let", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ] - } + "_id": 1 }, { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "crud-tests" - } + "_id": 2, + "name": "name" }, { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "coll0" - } + "_id": 3, + "name": "name" } - ], - "initialData": [ + ] + } + ], + "tests": [ + { + "description": "deleteMany with let option", + "runOnRequirements": [ { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2, - "name": "name" - }, - { - "_id": 3, - "name": "name" - } - ] + "minServerVersion": "5.0" } - ], - "tests": [ + ], + "operations": [ { - "description": "deleteMany with let option", - "runOnRequirements": [ - { - "minServerVersion": "5.0" - } - ], - "operations": [ - { - "name": "deleteMany", - "object": "collection0", - "arguments": { - "filter": { - "$expr": { - "$eq": [ - "$name", - "$$name" - ] - } - }, - "let": { - "name": "name" + "name": "deleteMany", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$name", + "$$name" + ] + } + }, + "let": { + "name": "name" + } + }, + "expectResult": { + "deletedCount": 2 + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "coll0", + "deletes": [ + { + "q": { + "$expr": { + "$eq": [ + "$name", + "$$name" + ] } - }, - "expectResult": { - "deletedCount": 2 + }, + "limit": 0 } + ], + "let": { + "name": "name" + } } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "delete": "coll0", - "deletes": [ - { - "q": { - "$expr": { - "$eq": [ - "$name", - "$$name" - ] - } - }, - "limit": 0 - } - ], - "let": { - "name": "name" - } - } - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - } - ] - } - ] - }, + } + } + ] + } + ], + "outcome": [ { - "description": "deleteMany with let option unsupported (server-side error)", - "runOnRequirements": [ - { - "minServerVersion": "3.6.0", - "maxServerVersion": "4.4.99" - } - ], - "operations": [ - { - "name": "deleteMany", - "object": "collection0", - "arguments": { - "filter": { - "$expr": { - "$eq": [ - "$name", - "$$name" - ] - } - }, - "let": { - "name": "name" + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "deleteMany with let option unsupported (server-side error)", + "runOnRequirements": [ + { + "minServerVersion": "3.6.0", + "maxServerVersion": "4.4.99" + } + ], + "operations": [ + { + "name": "deleteMany", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$name", + "$$name" + ] + } + }, + "let": { + "name": "name" + } + }, + "expectError": { + "errorContains": "'delete.let' is an unknown field", + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "coll0", + "deletes": [ + { + "q": { + "$expr": { + "$eq": [ + "$name", + "$$name" + ] } - }, - "expectError": { - "errorContains": "'delete.let' is an unknown field", - "isClientError": false + }, + "limit": 0 } + ], + "let": { + "name": "name" + } } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "delete": "coll0", - "deletes": [ - { - "q": { - "$expr": { - "$eq": [ - "$name", - "$$name" - ] - } - }, - "limit": 0 - } - ], - "let": { - "name": "name" - } - } - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2, - "name": "name" - }, - { - "_id": 3, - "name": "name" - } - ] - } - ] + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2, + "name": "name" + }, + { + "_id": 3, + "name": "name" + } + ] } - ] + ] + } + ] } diff --git a/test/spec/crud/unified/deleteOne-let.json b/test/spec/crud/unified/deleteOne-let.json index 7b7695c2739..9718682235d 100644 --- a/test/spec/crud/unified/deleteOne-let.json +++ b/test/spec/crud/unified/deleteOne-let.json @@ -1,191 +1,191 @@ { - "description": "deleteOne-let", - "schemaVersion": "1.0", - "createEntities": [ + "description": "deleteOne-let", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ] - } + "_id": 1 }, { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "crud-tests" - } - }, + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "deleteOne with let option", + "runOnRequirements": [ { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "coll0" - } + "minServerVersion": "5.0" } - ], - "initialData": [ + ], + "operations": [ { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] + "name": "deleteOne", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "let": { + "id": 1 + } + }, + "expectResult": { + "deletedCount": 1 + } } - ], - "tests": [ + ], + "expectEvents": [ { - "description": "deleteOne with let option", - "runOnRequirements": [ - { - "minServerVersion": "5.0" - } - ], - "operations": [ - { - "name": "deleteOne", - "object": "collection0", - "arguments": { - "filter": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "let": { - "id": 1 + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "coll0", + "deletes": [ + { + "q": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] } - }, - "expectResult": { - "deletedCount": 1 + }, + "limit": 1 } + ], + "let": { + "id": 1 + } } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "delete": "coll0", - "deletes": [ - { - "q": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "limit": 1 - } - ], - "let": { - "id": 1 - } - } - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 2 - } - ] - } - ] - }, + } + } + ] + } + ], + "outcome": [ { - "description": "deleteOne with let option unsupported (server-side error)", - "runOnRequirements": [ - { - "minServerVersion": "3.6.0", - "maxServerVersion": "4.4.99" - } - ], - "operations": [ - { - "name": "deleteOne", - "object": "collection0", - "arguments": { - "filter": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "let": { - "id": 1 + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 2 + } + ] + } + ] + }, + { + "description": "deleteOne with let option unsupported (server-side error)", + "runOnRequirements": [ + { + "minServerVersion": "3.6.0", + "maxServerVersion": "4.4.99" + } + ], + "operations": [ + { + "name": "deleteOne", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "let": { + "id": 1 + } + }, + "expectError": { + "errorContains": "'delete.let' is an unknown field", + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "coll0", + "deletes": [ + { + "q": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] } - }, - "expectError": { - "errorContains": "'delete.let' is an unknown field", - "isClientError": false + }, + "limit": 1 } + ], + "let": { + "id": 1 + } } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "delete": "coll0", - "deletes": [ - { - "q": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "limit": 1 - } - ], - "let": { - "id": 1 - } - } - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - ] + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] } - ] + ] + } + ] } diff --git a/test/spec/crud/unified/find-let.json b/test/spec/crud/unified/find-let.json index 752d8ac56c1..4e9c9c99f4f 100644 --- a/test/spec/crud/unified/find-let.json +++ b/test/spec/crud/unified/find-let.json @@ -1,148 +1,148 @@ { - "description": "find-let", - "schemaVersion": "1.0", - "createEntities": [ + "description": "find-let", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ] - } + "_id": 1 }, { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "crud-tests" - } - }, + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "Find with let option", + "runOnRequirements": [ + { + "minServerVersion": "5.0" + } + ], + "operations": [ { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "coll0" + "name": "find", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "let": { + "id": 1 + } + }, + "expectResult": [ + { + "_id": 1 } + ] } - ], - "initialData": [ + ], + "expectEvents": [ { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "find": "coll0", + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "let": { + "id": 1 + } } - ] + } + } + ] } - ], - "tests": [ + ] + }, + { + "description": "Find with let option unsupported (server-side error)", + "runOnRequirements": [ { - "description": "Find with let option", - "runOnRequirements": [ - { - "minServerVersion": "5.0" - } - ], - "operations": [ - { - "name": "find", - "object": "collection0", - "arguments": { - "filter": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "let": { - "id": 1 - } - }, - "expectResult": [ - { - "_id": 1 - } - ] - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "find": "coll0", - "filter": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "let": { - "id": 1 - } - } - } - } - ] - } - ] - }, + "minServerVersion": "3.6.0", + "maxServerVersion": "4.4.99" + } + ], + "operations": [ { - "description": "Find with let option unsupported (server-side error)", - "runOnRequirements": [ - { - "minServerVersion": "3.6.0", - "maxServerVersion": "4.4.99" - } - ], - "operations": [ - { - "name": "find", - "object": "collection0", - "arguments": { - "filter": { - "_id": 1 - }, - "let": { - "x": 1 - } - }, - "expectError": { - "errorContains": "Unrecognized field 'let'", - "isClientError": false - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "find": "coll0", - "filter": { - "_id": 1 - }, - "let": { - "x": 1 - } - } - } - } - ] + "name": "find", + "object": "collection0", + "arguments": { + "filter": { + "_id": 1 + }, + "let": { + "x": 1 + } + }, + "expectError": { + "errorContains": "Unrecognized field 'let'", + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "find": "coll0", + "filter": { + "_id": 1 + }, + "let": { + "x": 1 + } } - ] + } + } + ] } - ] + ] + } + ] } diff --git a/test/spec/crud/unified/findOneAndDelete-let.json b/test/spec/crud/unified/findOneAndDelete-let.json index 04107bf8e87..ba8e681c0e5 100644 --- a/test/spec/crud/unified/findOneAndDelete-let.json +++ b/test/spec/crud/unified/findOneAndDelete-let.json @@ -1,180 +1,180 @@ { - "description": "findOneAndDelete-let", - "schemaVersion": "1.0", - "createEntities": [ + "description": "findOneAndDelete-let", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "findOneAndDelete with let option", + "runOnRequirements": [ + { + "minServerVersion": "5.0" + } + ], + "operations": [ + { + "name": "findOneAndDelete", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" ] + } + }, + "let": { + "id": 1 } - }, + } + } + ], + "expectEvents": [ { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "crud-tests" + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "remove": true, + "let": { + "id": 1 + } + } + } } - }, + ] + } + ], + "outcome": [ { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "coll0" + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 2 } + ] } - ], - "initialData": [ + ] + }, + { + "description": "findOneAndDelete with let option unsupported (server-side error)", + "runOnRequirements": [ { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] + "minServerVersion": "4.2.0", + "maxServerVersion": "4.4.99" } - ], - "tests": [ + ], + "operations": [ { - "description": "findOneAndDelete with let option", - "runOnRequirements": [ - { - "minServerVersion": "5.0" - } - ], - "operations": [ - { - "name": "findOneAndDelete", - "object": "collection0", - "arguments": { - "filter": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "let": { - "id": 1 - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "findAndModify": "coll0", - "query": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "remove": true, - "let": { - "id": 1 - } - } - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 2 - } - ] - } - ] - }, + "name": "findOneAndDelete", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "let": { + "id": 1 + } + }, + "expectError": { + "errorContains": "field 'let' is an unknown field", + "isClientError": false + } + } + ], + "expectEvents": [ { - "description": "findOneAndDelete with let option unsupported (server-side error)", - "runOnRequirements": [ - { - "minServerVersion": "4.2.0", - "maxServerVersion": "4.4.99" - } - ], - "operations": [ - { - "name": "findOneAndDelete", - "object": "collection0", - "arguments": { - "filter": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "let": { - "id": 1 - } - }, - "expectError": { - "errorContains": "field 'let' is an unknown field", - "isClientError": false + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] } + }, + "remove": true, + "let": { + "id": 1 + } } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "findAndModify": "coll0", - "query": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "remove": true, - "let": { - "id": 1 - } - } - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - ] + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] } - ] + ] + } + ] } diff --git a/test/spec/crud/unified/findOneAndReplace-let.json b/test/spec/crud/unified/findOneAndReplace-let.json index e407f9b746c..5e5de44b311 100644 --- a/test/spec/crud/unified/findOneAndReplace-let.json +++ b/test/spec/crud/unified/findOneAndReplace-let.json @@ -1,197 +1,197 @@ { - "description": "findOneAndReplace-let", - "schemaVersion": "1.0", - "createEntities": [ + "description": "findOneAndReplace-let", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "findOneAndReplace with let option", + "runOnRequirements": [ + { + "minServerVersion": "5.0" + } + ], + "operations": [ + { + "name": "findOneAndReplace", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" ] + } + }, + "replacement": { + "x": "x" + }, + "let": { + "id": 1 } - }, + }, + "expectResult": { + "_id": 1 + } + } + ], + "expectEvents": [ { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "crud-tests" + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "update": { + "x": "x" + }, + "let": { + "id": 1 + } + } + } } - }, + ] + } + ], + "outcome": [ { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "coll0" + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": "x" + }, + { + "_id": 2 } + ] } - ], - "initialData": [ + ] + }, + { + "description": "findOneAndReplace with let option unsupported (server-side error)", + "runOnRequirements": [ { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] + "minServerVersion": "4.2.0", + "maxServerVersion": "4.4.99" } - ], - "tests": [ + ], + "operations": [ { - "description": "findOneAndReplace with let option", - "runOnRequirements": [ - { - "minServerVersion": "5.0" - } - ], - "operations": [ - { - "name": "findOneAndReplace", - "object": "collection0", - "arguments": { - "filter": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "replacement": { - "x": "x" - }, - "let": { - "id": 1 - } - }, - "expectResult": { - "_id": 1 - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "findAndModify": "coll0", - "query": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "update": { - "x": "x" - }, - "let": { - "id": 1 - } - } - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1, - "x": "x" - }, - { - "_id": 2 - } - ] - } - ] - }, + "name": "findOneAndReplace", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "replacement": { + "x": "x" + }, + "let": { + "id": 1 + } + }, + "expectError": { + "errorContains": "field 'let' is an unknown field", + "isClientError": false + } + } + ], + "expectEvents": [ { - "description": "findOneAndReplace with let option unsupported (server-side error)", - "runOnRequirements": [ - { - "minServerVersion": "4.2.0", - "maxServerVersion": "4.4.99" - } - ], - "operations": [ - { - "name": "findOneAndReplace", - "object": "collection0", - "arguments": { - "filter": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "replacement": { - "x": "x" - }, - "let": { - "id": 1 - } - }, - "expectError": { - "errorContains": "field 'let' is an unknown field", - "isClientError": false + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] } + }, + "update": { + "x": "x" + }, + "let": { + "id": 1 + } } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "findAndModify": "coll0", - "query": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "update": { - "x": "x" - }, - "let": { - "id": 1 - } - } - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - ] + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] } - ] + ] + } + ] } diff --git a/test/spec/crud/unified/findOneAndUpdate-let.json b/test/spec/crud/unified/findOneAndUpdate-let.json index 401e9fea83d..74d7d0e58bd 100644 --- a/test/spec/crud/unified/findOneAndUpdate-let.json +++ b/test/spec/crud/unified/findOneAndUpdate-let.json @@ -1,217 +1,217 @@ { - "description": "findOneAndUpdate-let", - "schemaVersion": "1.0", - "createEntities": [ + "description": "findOneAndUpdate-let", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ] - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "crud-tests" - } + "_id": 1 }, { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "coll0" - } + "_id": 2 } - ], - "initialData": [ + ] + } + ], + "tests": [ + { + "description": "findOneAndUpdate with let option", + "runOnRequirements": [ { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] + "minServerVersion": "5.0" } - ], - "tests": [ + ], + "operations": [ { - "description": "findOneAndUpdate with let option", - "runOnRequirements": [ - { - "minServerVersion": "5.0" + "name": "findOneAndUpdate", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "update": [ + { + "$set": { + "x": "$$x" } + } ], - "operations": [ - { - "name": "findOneAndUpdate", - "object": "collection0", - "arguments": { - "filter": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "update": [ - { - "$set": { - "x": "$$x" - } - } - ], - "let": { - "id": 1, - "x": "foo" - } - }, - "expectResult": { - "_id": 1 + "let": { + "id": 1, + "x": "foo" + } + }, + "expectResult": { + "_id": 1 + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] } + }, + "update": [ + { + "$set": { + "x": "$$x" + } + } + ], + "let": { + "id": 1, + "x": "foo" + } } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "findAndModify": "coll0", - "query": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "update": [ - { - "$set": { - "x": "$$x" - } - } - ], - "let": { - "id": 1, - "x": "foo" - } - } - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1, - "x": "foo" - }, - { - "_id": 2 - } - ] - } - ] - }, + } + } + ] + } + ], + "outcome": [ { - "description": "findOneAndUpdate with let option unsupported (server-side error)", - "runOnRequirements": [ - { - "minServerVersion": "4.2.0", - "maxServerVersion": "4.4.99" + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": "foo" + }, + { + "_id": 2 + } + ] + } + ] + }, + { + "description": "findOneAndUpdate with let option unsupported (server-side error)", + "runOnRequirements": [ + { + "minServerVersion": "4.2.0", + "maxServerVersion": "4.4.99" + } + ], + "operations": [ + { + "name": "findOneAndUpdate", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "update": [ + { + "$set": { + "x": "$$x" } + } ], - "operations": [ - { - "name": "findOneAndUpdate", - "object": "collection0", - "arguments": { - "filter": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "update": [ - { - "$set": { - "x": "$$x" - } - } - ], - "let": { - "id": 1, - "x": "foo" - } - }, - "expectError": { - "errorContains": "field 'let' is an unknown field", - "isClientError": false + "let": { + "id": 1, + "x": "foo" + } + }, + "expectError": { + "errorContains": "field 'let' is an unknown field", + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] } + }, + "update": [ + { + "$set": { + "x": "$$x" + } + } + ], + "let": { + "id": 1, + "x": "foo" + } } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "findAndModify": "coll0", - "query": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "update": [ - { - "$set": { - "x": "$$x" - } - } - ], - "let": { - "id": 1, - "x": "foo" - } - } - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - ] + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] } - ] + ] + } + ] } diff --git a/test/spec/crud/unified/updateMany-let.json b/test/spec/crud/unified/updateMany-let.json index 8a48aeb4a45..8a19ac09337 100644 --- a/test/spec/crud/unified/updateMany-let.json +++ b/test/spec/crud/unified/updateMany-let.json @@ -1,243 +1,243 @@ { - "description": "updateMany-let", - "schemaVersion": "1.0", - "createEntities": [ + "description": "updateMany-let", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ] - } + "_id": 1 }, { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "crud-tests" - } + "_id": 2, + "name": "name" }, { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "coll0" - } + "_id": 3, + "name": "name" } - ], - "initialData": [ + ] + } + ], + "tests": [ + { + "description": "updateMany with let option", + "runOnRequirements": [ { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2, - "name": "name" - }, - { - "_id": 3, - "name": "name" - } - ] + "minServerVersion": "5.0" } - ], - "tests": [ + ], + "operations": [ { - "description": "updateMany with let option", - "runOnRequirements": [ - { - "minServerVersion": "5.0" - } - ], - "operations": [ - { - "name": "updateMany", - "object": "collection0", - "arguments": { - "filter": { - "$expr": { - "$eq": [ - "$name", - "$$name" - ] - } - }, - "update": [ - { - "$set": { - "x": "$$x", - "y": "$$y" - } - } - ], - "let": { - "name": "name", - "x": "foo", - "y": { - "$literal": "bar" - } - } - }, - "expectResult": { - "matchedCount": 2, - "modifiedCount": 2, - "upsertedCount": 0 - } + "name": "updateMany", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$name", + "$$name" + ] + } + }, + "update": [ + { + "$set": { + "x": "$$x", + "y": "$$y" } + } ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "update": "coll0", - "updates": [ - { - "q": { - "$expr": { - "$eq": [ - "$name", - "$$name" - ] - } - }, - "u": [ - { - "$set": { - "x": "$$x", - "y": "$$y" - } - } - ], - "multi": true - } - ], - "let": { - "name": "name", - "x": "foo", - "y": { - "$literal": "bar" - } - } - } - } + "let": { + "name": "name", + "x": "foo", + "y": { + "$literal": "bar" + } + } + }, + "expectResult": { + "matchedCount": 2, + "modifiedCount": 2, + "upsertedCount": 0 + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": { + "$expr": { + "$eq": [ + "$name", + "$$name" + ] } - ] - } - ], - "outcome": [ - { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2, - "name": "name", - "x": "foo", - "y": "bar" - }, + }, + "u": [ { - "_id": 3, - "name": "name", - "x": "foo", - "y": "bar" - } - ] - } - ] - }, - { - "description": "updateMany with let option unsupported (server-side error)", - "runOnRequirements": [ - { - "minServerVersion": "4.2.0", - "maxServerVersion": "4.4.99" - } - ], - "operations": [ - { - "name": "updateMany", - "object": "collection0", - "arguments": { - "filter": { - "_id": 1 - }, - "update": [ - { - "$set": { - "x": "$$x" - } - } - ], - "let": { - "x": "foo" + "$set": { + "x": "$$x", + "y": "$$y" + } } - }, - "expectError": { - "errorContains": "'update.let' is an unknown field", - "isClientError": false + ], + "multi": true + } + ], + "let": { + "name": "name", + "x": "foo", + "y": { + "$literal": "bar" } + } } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "update": "coll0", - "updates": [ - { - "q": { - "_id": 1 - }, - "u": [ - { - "$set": { - "x": "$$x" - } - } - ], - "multi": true - } - ], - "let": { - "x": "foo" - } - } - } - } - ] + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2, + "name": "name", + "x": "foo", + "y": "bar" + }, + { + "_id": 3, + "name": "name", + "x": "foo", + "y": "bar" + } + ] + } + ] + }, + { + "description": "updateMany with let option unsupported (server-side error)", + "runOnRequirements": [ + { + "minServerVersion": "4.2.0", + "maxServerVersion": "4.4.99" + } + ], + "operations": [ + { + "name": "updateMany", + "object": "collection0", + "arguments": { + "filter": { + "_id": 1 + }, + "update": [ + { + "$set": { + "x": "$$x" } + } ], - "outcome": [ - { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2, - "name": "name" - }, + "let": { + "x": "foo" + } + }, + "expectError": { + "errorContains": "'update.let' is an unknown field", + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": { + "_id": 1 + }, + "u": [ { - "_id": 3, - "name": "name" + "$set": { + "x": "$$x" + } } - ] + ], + "multi": true + } + ], + "let": { + "x": "foo" + } } - ] + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2, + "name": "name" + }, + { + "_id": 3, + "name": "name" + } + ] } - ] + ] + } + ] } diff --git a/test/spec/crud/unified/updateOne-let.json b/test/spec/crud/unified/updateOne-let.json index 001da55505e..8237bef7e85 100644 --- a/test/spec/crud/unified/updateOne-let.json +++ b/test/spec/crud/unified/updateOne-let.json @@ -1,215 +1,215 @@ { - "description": "updateOne-let", - "schemaVersion": "1.0", - "createEntities": [ + "description": "updateOne-let", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ] - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "crud-tests" - } + "_id": 1 }, { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "coll0" - } + "_id": 2 } - ], - "initialData": [ + ] + } + ], + "tests": [ + { + "description": "UpdateOne with let option", + "runOnRequirements": [ { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] + "minServerVersion": "5.0" } - ], - "tests": [ + ], + "operations": [ { - "description": "UpdateOne with let option", - "runOnRequirements": [ - { - "minServerVersion": "5.0" - } - ], - "operations": [ - { - "name": "updateOne", - "object": "collection0", - "arguments": { - "filter": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "update": [ - { - "$set": { - "x": "$$x" - } - } - ], - "let": { - "id": 1, - "x": "foo" - } - }, - "expectResult": { - "matchedCount": 1, - "modifiedCount": 1, - "upsertedCount": 0 - } + "name": "updateOne", + "object": "collection0", + "arguments": { + "filter": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] + } + }, + "update": [ + { + "$set": { + "x": "$$x" } + } ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "update": "coll0", - "updates": [ - { - "q": { - "$expr": { - "$eq": [ - "$_id", - "$$id" - ] - } - }, - "u": [ - { - "$set": { - "x": "$$x" - } - } - ] - } - ], - "let": { - "id": 1, - "x": "foo" - } - } - } + "let": { + "id": 1, + "x": "foo" + } + }, + "expectResult": { + "matchedCount": 1, + "modifiedCount": 1, + "upsertedCount": 0 + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": { + "$expr": { + "$eq": [ + "$_id", + "$$id" + ] } - ] - } - ], - "outcome": [ - { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ + }, + "u": [ { - "_id": 1, - "x": "foo" - }, - { - "_id": 2 + "$set": { + "x": "$$x" + } } - ] - } - ] - }, - { - "description": "UpdateOne with let option unsupported (server-side error)", - "runOnRequirements": [ - { - "minServerVersion": "4.2.0", - "maxServerVersion": "4.4.99" - } - ], - "operations": [ - { - "name": "updateOne", - "object": "collection0", - "arguments": { - "filter": { - "_id": 1 - }, - "update": [ - { - "$set": { - "x": "$$x" - } - } - ], - "let": { - "x": "foo" - } - }, - "expectError": { - "errorContains": "'update.let' is an unknown field", - "isClientError": false + ] } + ], + "let": { + "id": 1, + "x": "foo" + } } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "update": "coll0", - "updates": [ - { - "q": { - "_id": 1 - }, - "u": [ - { - "$set": { - "x": "$$x" - } - } - ] - } - ], - "let": { - "x": "foo" - } - } - } - } - ] + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": "foo" + }, + { + "_id": 2 + } + ] + } + ] + }, + { + "description": "UpdateOne with let option unsupported (server-side error)", + "runOnRequirements": [ + { + "minServerVersion": "4.2.0", + "maxServerVersion": "4.4.99" + } + ], + "operations": [ + { + "name": "updateOne", + "object": "collection0", + "arguments": { + "filter": { + "_id": 1 + }, + "update": [ + { + "$set": { + "x": "$$x" } + } ], - "outcome": [ - { - "collectionName": "coll0", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1 - }, + "let": { + "x": "foo" + } + }, + "expectError": { + "errorContains": "'update.let' is an unknown field", + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": { + "_id": 1 + }, + "u": [ { - "_id": 2 + "$set": { + "x": "$$x" + } } - ] + ] + } + ], + "let": { + "x": "foo" + } } - ] + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] } - ] + ] + } + ] }