...
1description: "replaceOne-dots_and_dollars"
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 - collection:
18 id: &collection1 collection1
19 database: *database0
20 collectionName: &collection1Name coll1
21 collectionOptions:
22 writeConcern: { w: 0 }
23
24initialData: &initialData
25 - collectionName: *collection0Name
26 databaseName: *database0Name
27 documents:
28 - { _id: 1 }
29
30tests:
31 - description: "Replacing document with top-level dotted key on 3.6+ server"
32 runOnRequirements:
33 - minServerVersion: "3.6"
34 operations:
35 - name: replaceOne
36 object: *collection0
37 arguments:
38 filter: { _id: 1 }
39 replacement: &dottedKey { _id: 1, a.b: 1 }
40 expectResult: &replaceResult
41 matchedCount: 1
42 modifiedCount: 1
43 upsertedCount: 0
44 expectEvents: &expectEventsDottedKey
45 - client: *client0
46 events:
47 - commandStartedEvent:
48 command:
49 update: *collection0Name
50 updates:
51 - q: { _id: 1 }
52 u: *dottedKey
53 multi: { $$unsetOrMatches: false }
54 upsert: { $$unsetOrMatches: false }
55 outcome:
56 - collectionName: *collection0Name
57 databaseName: *database0Name
58 documents:
59 - *dottedKey
60
61 - description: "Replacing document with top-level dotted key on pre-3.6 server yields server-side error"
62 runOnRequirements:
63 - maxServerVersion: "3.4.99"
64 operations:
65 - name: replaceOne
66 object: *collection0
67 arguments:
68 filter: { _id: 1 }
69 replacement: *dottedKey
70 expectError:
71 isClientError: false
72 expectEvents: *expectEventsDottedKey
73 outcome: *initialData
74
75 - description: "Replacing document with dollar-prefixed key in embedded doc on 5.0+ server"
76 runOnRequirements:
77 - minServerVersion: "5.0"
78 operations:
79 - name: replaceOne
80 object: *collection0
81 arguments:
82 filter: { _id: 1 }
83 replacement: &dollarPrefixedKeyInEmbedded { _id: 1, a: { $b: 1 } }
84 expectResult: *replaceResult
85 expectEvents: &expectEventsDollarPrefixedKeyInEmbedded
86 - client: *client0
87 events:
88 - commandStartedEvent:
89 command:
90 update: *collection0Name
91 updates:
92 - q: { _id: 1 }
93 u: *dollarPrefixedKeyInEmbedded
94 multi: { $$unsetOrMatches: false }
95 upsert: { $$unsetOrMatches: false }
96 outcome:
97 - collectionName: *collection0Name
98 databaseName: *database0Name
99 documents:
100 - *dollarPrefixedKeyInEmbedded
101
102 - description: "Replacing document with dollar-prefixed key in embedded doc on pre-5.0 server yields server-side error"
103 runOnRequirements:
104 - maxServerVersion: "4.99"
105 operations:
106 - name: replaceOne
107 object: *collection0
108 arguments:
109 filter: { _id: 1 }
110 replacement: *dollarPrefixedKeyInEmbedded
111 expectError:
112 isClientError: false
113 expectEvents: *expectEventsDollarPrefixedKeyInEmbedded
114 outcome: *initialData
115
116 - description: "Replacing document with dotted key in embedded doc on 3.6+ server"
117 runOnRequirements:
118 - minServerVersion: "3.6"
119 operations:
120 - name: replaceOne
121 object: *collection0
122 arguments:
123 filter: { _id: 1 }
124 replacement: &dottedKeyInEmbedded { _id: 1, a: { b.c: 1 } }
125 expectResult: *replaceResult
126 expectEvents: &expectEventsDottedKeyInEmbedded
127 - client: *client0
128 events:
129 - commandStartedEvent:
130 command:
131 update: *collection0Name
132 updates:
133 - q: { _id: 1 }
134 u: *dottedKeyInEmbedded
135 multi: { $$unsetOrMatches: false }
136 upsert: { $$unsetOrMatches: false }
137 outcome:
138 - collectionName: *collection0Name
139 databaseName: *database0Name
140 documents:
141 - *dottedKeyInEmbedded
142
143 - description: "Replacing document with dotted key in embedded doc on pre-3.6 server yields server-side error"
144 runOnRequirements:
145 - maxServerVersion: "3.4.99"
146 operations:
147 - name: replaceOne
148 object: *collection0
149 arguments:
150 filter: { _id: 1 }
151 replacement: *dottedKeyInEmbedded
152 expectError:
153 isClientError: false
154 expectEvents: *expectEventsDottedKeyInEmbedded
155 outcome: *initialData
156
157 - description: "Unacknowledged write using dollar-prefixed or dotted keys may be silently rejected on pre-5.0 server"
158 runOnRequirements:
159 - maxServerVersion: "4.99"
160 operations:
161 - name: replaceOne
162 object: *collection1
163 arguments:
164 filter: { _id: 1 }
165 replacement: *dollarPrefixedKeyInEmbedded
166 expectResult:
167 acknowledged: { $$unsetOrMatches: false }
168 expectEvents:
169 - client: *client0
170 events:
171 - commandStartedEvent:
172 command:
173 update: *collection1Name
174 updates:
175 - q: { _id: 1 }
176 u: *dollarPrefixedKeyInEmbedded
177 multi: { $$unsetOrMatches: false }
178 upsert: { $$unsetOrMatches: false }
179 writeConcern: { w: 0 }
180 outcome: *initialData
View as plain text