1{
2 "description": "findOneAndUpdate-dots_and_dollars",
3 "schemaVersion": "1.0",
4 "createEntities": [
5 {
6 "client": {
7 "id": "client0",
8 "observeEvents": [
9 "commandStartedEvent"
10 ]
11 }
12 },
13 {
14 "database": {
15 "id": "database0",
16 "client": "client0",
17 "databaseName": "crud-tests"
18 }
19 },
20 {
21 "collection": {
22 "id": "collection0",
23 "database": "database0",
24 "collectionName": "coll0"
25 }
26 }
27 ],
28 "initialData": [
29 {
30 "collectionName": "coll0",
31 "databaseName": "crud-tests",
32 "documents": [
33 {
34 "_id": 1,
35 "foo": {}
36 }
37 ]
38 }
39 ],
40 "tests": [
41 {
42 "description": "Updating document to set top-level dollar-prefixed key on 5.0+ server",
43 "runOnRequirements": [
44 {
45 "minServerVersion": "5.0"
46 }
47 ],
48 "operations": [
49 {
50 "name": "findOneAndUpdate",
51 "object": "collection0",
52 "arguments": {
53 "filter": {
54 "_id": 1
55 },
56 "update": [
57 {
58 "$replaceWith": {
59 "$setField": {
60 "field": {
61 "$literal": "$a"
62 },
63 "value": 1,
64 "input": "$$ROOT"
65 }
66 }
67 }
68 ]
69 },
70 "expectResult": {
71 "_id": 1,
72 "foo": {}
73 }
74 }
75 ],
76 "expectEvents": [
77 {
78 "client": "client0",
79 "events": [
80 {
81 "commandStartedEvent": {
82 "command": {
83 "findAndModify": "coll0",
84 "query": {
85 "_id": 1
86 },
87 "update": [
88 {
89 "$replaceWith": {
90 "$setField": {
91 "field": {
92 "$literal": "$a"
93 },
94 "value": 1,
95 "input": "$$ROOT"
96 }
97 }
98 }
99 ],
100 "new": {
101 "$$unsetOrMatches": false
102 }
103 }
104 }
105 }
106 ]
107 }
108 ],
109 "outcome": [
110 {
111 "collectionName": "coll0",
112 "databaseName": "crud-tests",
113 "documents": [
114 {
115 "_id": 1,
116 "foo": {},
117 "$a": 1
118 }
119 ]
120 }
121 ]
122 },
123 {
124 "description": "Updating document to set top-level dotted key on 5.0+ server",
125 "runOnRequirements": [
126 {
127 "minServerVersion": "5.0"
128 }
129 ],
130 "operations": [
131 {
132 "name": "findOneAndUpdate",
133 "object": "collection0",
134 "arguments": {
135 "filter": {
136 "_id": 1
137 },
138 "update": [
139 {
140 "$replaceWith": {
141 "$setField": {
142 "field": {
143 "$literal": "a.b"
144 },
145 "value": 1,
146 "input": "$$ROOT"
147 }
148 }
149 }
150 ]
151 },
152 "expectResult": {
153 "_id": 1,
154 "foo": {}
155 }
156 }
157 ],
158 "expectEvents": [
159 {
160 "client": "client0",
161 "events": [
162 {
163 "commandStartedEvent": {
164 "command": {
165 "findAndModify": "coll0",
166 "query": {
167 "_id": 1
168 },
169 "update": [
170 {
171 "$replaceWith": {
172 "$setField": {
173 "field": {
174 "$literal": "a.b"
175 },
176 "value": 1,
177 "input": "$$ROOT"
178 }
179 }
180 }
181 ],
182 "new": {
183 "$$unsetOrMatches": false
184 }
185 }
186 }
187 }
188 ]
189 }
190 ],
191 "outcome": [
192 {
193 "collectionName": "coll0",
194 "databaseName": "crud-tests",
195 "documents": [
196 {
197 "_id": 1,
198 "foo": {},
199 "a.b": 1
200 }
201 ]
202 }
203 ]
204 },
205 {
206 "description": "Updating document to set dollar-prefixed key in embedded doc on 5.0+ server",
207 "runOnRequirements": [
208 {
209 "minServerVersion": "5.0"
210 }
211 ],
212 "operations": [
213 {
214 "name": "findOneAndUpdate",
215 "object": "collection0",
216 "arguments": {
217 "filter": {
218 "_id": 1
219 },
220 "update": [
221 {
222 "$set": {
223 "foo": {
224 "$setField": {
225 "field": {
226 "$literal": "$a"
227 },
228 "value": 1,
229 "input": "$foo"
230 }
231 }
232 }
233 }
234 ]
235 },
236 "expectResult": {
237 "_id": 1,
238 "foo": {}
239 }
240 }
241 ],
242 "expectEvents": [
243 {
244 "client": "client0",
245 "events": [
246 {
247 "commandStartedEvent": {
248 "command": {
249 "findAndModify": "coll0",
250 "query": {
251 "_id": 1
252 },
253 "update": [
254 {
255 "$set": {
256 "foo": {
257 "$setField": {
258 "field": {
259 "$literal": "$a"
260 },
261 "value": 1,
262 "input": "$foo"
263 }
264 }
265 }
266 }
267 ],
268 "new": {
269 "$$unsetOrMatches": false
270 }
271 }
272 }
273 }
274 ]
275 }
276 ],
277 "outcome": [
278 {
279 "collectionName": "coll0",
280 "databaseName": "crud-tests",
281 "documents": [
282 {
283 "_id": 1,
284 "foo": {
285 "$a": 1
286 }
287 }
288 ]
289 }
290 ]
291 },
292 {
293 "description": "Updating document to set dotted key in embedded doc on 5.0+ server",
294 "runOnRequirements": [
295 {
296 "minServerVersion": "5.0"
297 }
298 ],
299 "operations": [
300 {
301 "name": "findOneAndUpdate",
302 "object": "collection0",
303 "arguments": {
304 "filter": {
305 "_id": 1
306 },
307 "update": [
308 {
309 "$set": {
310 "foo": {
311 "$setField": {
312 "field": {
313 "$literal": "a.b"
314 },
315 "value": 1,
316 "input": "$foo"
317 }
318 }
319 }
320 }
321 ]
322 },
323 "expectResult": {
324 "_id": 1,
325 "foo": {}
326 }
327 }
328 ],
329 "expectEvents": [
330 {
331 "client": "client0",
332 "events": [
333 {
334 "commandStartedEvent": {
335 "command": {
336 "findAndModify": "coll0",
337 "query": {
338 "_id": 1
339 },
340 "update": [
341 {
342 "$set": {
343 "foo": {
344 "$setField": {
345 "field": {
346 "$literal": "a.b"
347 },
348 "value": 1,
349 "input": "$foo"
350 }
351 }
352 }
353 }
354 ],
355 "new": {
356 "$$unsetOrMatches": false
357 }
358 }
359 }
360 }
361 ]
362 }
363 ],
364 "outcome": [
365 {
366 "collectionName": "coll0",
367 "databaseName": "crud-tests",
368 "documents": [
369 {
370 "_id": 1,
371 "foo": {
372 "a.b": 1
373 }
374 }
375 ]
376 }
377 ]
378 }
379 ]
380}
View as plain text