...
1description: "findOneAndUpdate-let"
2
3schemaVersion: "1.0"
4
5createEntities:
6 - client:
7 id: &client0 client0
8 observeEvents: [ commandStartedEvent ]
9 - database:
10 id: &database0 database0
11 client: *client0
12 databaseName: &database0Name crud-tests
13 - collection:
14 id: &collection0 collection0
15 database: *database0
16 collectionName: &collection0Name coll0
17
18initialData: &initialData
19 - collectionName: *collection0Name
20 databaseName: *database0Name
21 documents:
22 - { _id: 1 }
23 - { _id: 2 }
24
25tests:
26 - description: "findOneAndUpdate with let option"
27 runOnRequirements:
28 - minServerVersion: "5.0"
29 operations:
30 - name: findOneAndUpdate
31 object: *collection0
32 arguments:
33 filter: &filter
34 $expr:
35 $eq: [ "$_id", "$$id" ]
36 update: &update
37 - $set: {x: "$$x" }
38 let: &let0
39 id: 1
40 x: "foo"
41 expectResult:
42 _id: 1
43 expectEvents:
44 - client: *client0
45 events:
46 - commandStartedEvent:
47 command:
48 findAndModify: *collection0Name
49 query: *filter
50 update: *update
51 let: *let0
52 outcome:
53 -
54 collectionName: *collection0Name
55 databaseName: *database0Name
56 documents:
57 - { _id: 1, x: "foo" }
58 - { _id: 2 }
59
60 - description: "findOneAndUpdate with let option unsupported (server-side error)"
61 runOnRequirements:
62 - minServerVersion: "4.2.0"
63 maxServerVersion: "4.4.99"
64 operations:
65 - name: findOneAndUpdate
66 object: *collection0
67 arguments:
68 filter: &filter1
69 $expr:
70 $eq: [ "$_id", "$$id" ]
71 update: &update1
72 - $set: {x: "$$x"}
73 let: &let1
74 id: 1
75 x: "foo"
76 expectError:
77 # This error message is consistent between 4.2.x and 4.4.x servers.
78 # Older servers return a different error message.
79 errorContains: "field 'let' is an unknown field"
80 isClientError: false
81 expectEvents:
82 - client: *client0
83 events:
84 - commandStartedEvent:
85 command:
86 findAndModify: *collection0Name
87 query: *filter1
88 update: *update1
89 let: *let1
90 outcome:
91 -
92 collectionName: *collection0Name
93 databaseName: *database0Name
94 documents:
95 - { _id: 1 }
96 - { _id: 2 }
View as plain text