Skip to content

Commit 0fc77cd

Browse files
DRIVERS-2189 getMore sends inherited comment (#1141)
1 parent 96caeef commit 0fc77cd

File tree

9 files changed

+154
-37
lines changed

9 files changed

+154
-37
lines changed

source/change-streams/change-streams.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Change Streams
99
:Status: Accepted
1010
:Type: Standards
1111
:Minimum Server Version: 3.6
12-
:Last Modified: 2022-02-01
13-
:Version: 1.11
12+
:Last Modified: 2022-02-10
13+
:Version: 1.12
1414

1515
.. contents::
1616

@@ -417,6 +417,9 @@ Driver API
417417
* Server versions prior to 4.4 only support string as comment,
418418
* and providing a non-string type will result in a server-side error.
419419
*
420+
* If a comment is provided, drivers MUST attach this comment to all
421+
* subsequent getMore commands run on the same cursor.
422+
*
420423
* @see https://docs.mongodb.com/manual/reference/command/aggregate
421424
* @note this is an aggregation command option
422425
*/
@@ -915,3 +918,6 @@ Changelog
915918
+------------+------------------------------------------------------------+
916919
| 2022-02-01 | Added ``comment`` to ``ChangeStreamOptions``. |
917920
+------------+------------------------------------------------------------+
921+
| 2022-02-10 | Specified that ``getMore`` command must explicitly send |
922+
| | inherited ``comment``. |
923+
+------------+------------------------------------------------------------+

source/change-streams/tests/unified/change-streams.json

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,88 @@
247247
]
248248
}
249249
]
250+
},
251+
{
252+
"description": "Test that comment is set on getMore",
253+
"runOnRequirements": [
254+
{
255+
"minServerVersion": "3.6.0"
256+
}
257+
],
258+
"operations": [
259+
{
260+
"name": "createChangeStream",
261+
"object": "collection0",
262+
"arguments": {
263+
"pipeline": [],
264+
"comment": "comment"
265+
},
266+
"saveResultAsEntity": "changeStream0"
267+
},
268+
{
269+
"name": "insertOne",
270+
"object": "collection0",
271+
"arguments": {
272+
"document": {
273+
"_id": 1,
274+
"a": 1
275+
}
276+
}
277+
},
278+
{
279+
"name": "iterateUntilDocumentOrError",
280+
"object": "changeStream0"
281+
}
282+
],
283+
"expectEvents": [
284+
{
285+
"client": "client0",
286+
"events": [
287+
{
288+
"commandStartedEvent": {
289+
"command": {
290+
"aggregate": "collection0",
291+
"pipeline": [
292+
{
293+
"$changeStream": {}
294+
}
295+
],
296+
"comment": "comment"
297+
}
298+
}
299+
},
300+
{
301+
"commandStartedEvent": {
302+
"command": {
303+
"insert": "collection0",
304+
"documents": [
305+
{
306+
"_id": 1,
307+
"a": 1
308+
}
309+
]
310+
}
311+
}
312+
},
313+
{
314+
"commandStartedEvent": {
315+
"command": {
316+
"getMore": {
317+
"$$type": [
318+
"int",
319+
"long"
320+
]
321+
},
322+
"collection": "collection0",
323+
"comment": "comment"
324+
},
325+
"commandName": "getMore",
326+
"databaseName": "database0"
327+
}
328+
}
329+
]
330+
}
331+
]
250332
}
251333
]
252334
}

source/change-streams/tests/unified/change-streams.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,43 @@ tests:
136136
pipeline:
137137
- $changeStream: {}
138138
comment: "comment"
139+
140+
- description: "Test that comment is set on getMore"
141+
runOnRequirements:
142+
- minServerVersion: "3.6.0"
143+
operations:
144+
- name: createChangeStream
145+
object: *collection0
146+
arguments:
147+
pipeline: []
148+
comment: "comment"
149+
saveResultAsEntity: &changeStream0 changeStream0
150+
- name: insertOne
151+
object: *collection0
152+
arguments:
153+
document: &new_document
154+
_id: 1
155+
a: 1
156+
- name: iterateUntilDocumentOrError
157+
object: *changeStream0
158+
expectEvents:
159+
- client: *client0
160+
events:
161+
- commandStartedEvent:
162+
command:
163+
aggregate: *collection0
164+
pipeline:
165+
- $changeStream: {}
166+
comment: "comment"
167+
- commandStartedEvent:
168+
command:
169+
insert: *collection0
170+
documents:
171+
- *new_document
172+
- commandStartedEvent:
173+
command:
174+
getMore: { $$type: [ int, long ] }
175+
collection: *collection0
176+
comment: "comment"
177+
commandName: getMore
178+
databaseName: *database0

source/crud/crud.rst

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Driver CRUD API
1212
:Status: Approved
1313
:Type: Standards
1414
:Minimum Server Version: 2.6
15-
:Last Modified: 2022-02-01
15+
:Last Modified: 2022-02-10
1616

1717
.. contents::
1818

@@ -311,10 +311,8 @@ Read
311311
* Older server versions do not support comment for aggregate command at all,
312312
* and providing one will result in a server-side error.
313313
*
314-
* Any comment set on a aggregate command is inherited by any subsequent
315-
* getMore commands run on the same cursor.id returned from the
316-
* aggregate command. Therefore, drivers MUST NOT attach the comment
317-
* to subsequent getMore commands on a cursor.
314+
* If a comment is provided, drivers MUST attach this comment to all
315+
* subsequent getMore commands run on the same cursor.
318316
*/
319317
comment: Optional<any>;
320318
@@ -524,10 +522,8 @@ Read
524522
* Server versions prior to 4.4 only support string as comment,
525523
* and providing a non-string type will result in a server-side error.
526524
*
527-
* Any comment set on a find command is inherited by any subsequent
528-
* getMore commands run on the same cursor.id returned from the
529-
* find command. Therefore, drivers MUST NOT attach the comment
530-
* to subsequent getMore commands on a cursor.
525+
* If a comment is provided, drivers MUST attach this comment to all
526+
* subsequent getMore commands run on the same cursor.
531527
*/
532528
comment: Optional<any>;
533529
@@ -2331,6 +2327,7 @@ Q: Why are client-side errors raised for some unsupported options?
23312327
Changes
23322328
=======
23332329

2330+
* 2022-02-10: Specified that ``getMore`` command must explicitly send inherited comment.
23342331
* 2022-02-01: Add comment attribute to all helpers.
23352332
* 2022-01-27: Use optional return types for write commands and findAndModify
23362333
* 2022-01-19: Deprecate the maxTimeMS option and require that timeouts be applied per the client-side operations timeout spec.

source/crud/tests/unified/aggregate.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@
327327
]
328328
},
329329
{
330-
"description": "aggregate with comment does not set comment on getMore",
330+
"description": "aggregate with comment sets comment on getMore",
331331
"runOnRequirements": [
332332
{
333333
"minServerVersion": "3.6.0"
@@ -411,9 +411,7 @@
411411
},
412412
"collection": "coll0",
413413
"batchSize": 2,
414-
"comment": {
415-
"$$exists": false
416-
}
414+
"comment": "comment"
417415
},
418416
"commandName": "getMore",
419417
"databaseName": "aggregate-tests"
@@ -430,9 +428,7 @@
430428
},
431429
"collection": "coll0",
432430
"batchSize": 2,
433-
"comment": {
434-
"$$exists": false
435-
}
431+
"comment": "comment"
436432
},
437433
"commandName": "getMore",
438434
"databaseName": "aggregate-tests"

source/crud/tests/unified/aggregate.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ tests:
125125
commandName: aggregate
126126
databaseName: *database0Name
127127

128-
- description: "aggregate with comment does not set comment on getMore"
128+
- description: "aggregate with comment sets comment on getMore"
129129
runOnRequirements:
130130
- minServerVersion: "3.6.0"
131131
operations:
@@ -157,14 +157,14 @@ tests:
157157
getMore: { $$type: [ int, long ] }
158158
collection: *collection0Name
159159
batchSize: 2
160-
comment: { $$exists: false }
160+
comment: "comment"
161161
commandName: getMore
162162
databaseName: *database0Name
163163
- commandStartedEvent:
164164
command:
165165
getMore: { $$type: [ int, long ] }
166166
collection: *collection0Name
167167
batchSize: 2
168-
comment: { $$exists: false }
168+
comment: "comment"
169169
commandName: getMore
170170
databaseName: *database0Name

source/crud/tests/unified/find-comment.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
]
196196
},
197197
{
198-
"description": "find with comment does not set comment on getMore",
198+
"description": "find with comment sets comment on getMore",
199199
"runOnRequirements": [
200200
{
201201
"minServerVersion": "3.6"
@@ -267,9 +267,7 @@
267267
},
268268
"collection": "coll0",
269269
"batchSize": 2,
270-
"comment": {
271-
"$$exists": false
272-
}
270+
"comment": "comment"
273271
}
274272
}
275273
},
@@ -284,9 +282,7 @@
284282
},
285283
"collection": "coll0",
286284
"batchSize": 2,
287-
"comment": {
288-
"$$exists": false
289-
}
285+
"comment": "comment"
290286
}
291287
}
292288
}

source/crud/tests/unified/find-comment.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ tests:
8888
filter: *filter
8989
comment: *comment
9090

91-
- description: "find with comment does not set comment on getMore"
91+
- description: "find with comment sets comment on getMore"
9292
runOnRequirements:
9393
- minServerVersion: "3.6"
9494
operations:
@@ -118,10 +118,10 @@ tests:
118118
getMore: { $$type: [ int, long ] }
119119
collection: *collection0Name
120120
batchSize: 2
121-
comment: { $$exists: false }
121+
comment: "comment"
122122
- commandStartedEvent:
123123
command:
124124
getMore: { $$type: [ int, long ] }
125125
collection: *collection0Name
126126
batchSize: 2
127-
comment: { $$exists: false }
127+
comment: "comment"

source/index-management.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Index Management
1111
:Status: Approved
1212
:Type: Standards
1313
:Minimum Server Version: 2.4
14-
:Last Modified: 2022-01-01
15-
:Version: 1.8
14+
:Last Modified: 2022-02-10
15+
:Version: 1.9
1616

1717
.. contents::
1818

@@ -828,10 +828,8 @@ Common API Components
828828
* Enables users to specify an arbitrary comment to help trace the operation through
829829
* the database profiler, currentOp and logs. The default is to not send a value.
830830
*
831-
* Any comment set on a listIndexes command is inherited by any subsequent
832-
* getMore commands run on the same cursor.id returned from the
833-
* listIndexes command. Therefore, drivers MUST NOT attach the comment
834-
* to subsequent getMore commands on a cursor.
831+
* If a comment is provided, drivers MUST attach this comment to all
832+
* subsequent getMore commands run on the same cursor.
835833
*
836834
* @see https://docs.mongodb.com/manual/reference/command/listIndexes/
837835
*
@@ -899,3 +897,5 @@ Changelog
899897
- Require that timeouts be applied per the client-side operations timeout spec.
900898
01 FEB 2022:
901899
- Added comment field to helper methods.
900+
10 FEB 2022:
901+
- Specified that ``getMore`` command must explicitly send inherited comment.

0 commit comments

Comments
 (0)