...
1description: "updateMany-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, name: "name" }
24 - { _id: 3, name: "name" }
25
26
27tests:
28 - description: "updateMany with let option"
29 runOnRequirements:
30 - minServerVersion: "5.0"
31 operations:
32 - name: updateMany
33 object: *collection0
34 arguments:
35 filter: &filter
36 $expr:
37 $eq: [ "$name", "$$name" ]
38 update: &update
39 - $set: {x: "$$x", y: "$$y" }
40 let: &let0
41 name: name
42 x: foo
43 y: { $literal: "bar" }
44 expectResult:
45 matchedCount: 2
46 modifiedCount: 2
47 upsertedCount: 0
48 expectEvents:
49 - client: *client0
50 events:
51 - commandStartedEvent:
52 command:
53 update: *collection0Name
54 updates:
55 -
56 q: *filter
57 u: *update
58 multi: true
59 upsert: { $$unsetOrMatches: false }
60 let: *let0
61 outcome:
62 -
63 collectionName: *collection0Name
64 databaseName: *database0Name
65 documents:
66 - { _id: 1 }
67 - { _id: 2, name: "name", x: "foo", y: "bar" }
68 - { _id: 3, name: "name", x: "foo", y: "bar" }
69
70 - description: "updateMany with let option unsupported (server-side error)"
71 runOnRequirements:
72 - minServerVersion: "4.2.0"
73 maxServerVersion: "4.4.99"
74 operations:
75 - name: updateMany
76 object: *collection0
77 arguments:
78 filter: &filter1
79 _id: 1
80 update: &update1
81 - $set: {x: "$$x"}
82 let: &let1
83 x: foo
84 expectError:
85 errorContains: "'update.let' is an unknown field"
86 isClientError: false
87 expectEvents:
88 - client: *client0
89 events:
90 - commandStartedEvent:
91 command:
92 update: *collection0Name
93 updates:
94 -
95 q: *filter1
96 u: *update1
97 multi: true
98 upsert: { $$unsetOrMatches: false }
99 let: *let1
100 outcome:
101 -
102 collectionName: *collection0Name
103 databaseName: *database0Name
104 documents:
105 - { _id: 1 }
106 - { _id: 2, name: "name" }
107 - { _id: 3, name: "name" }
View as plain text