Skip to content

Commit af7c992

Browse files
authored
DRIVERS-1343 Include the "to" field in ChangeStreamDocument (#1138)
1 parent 52759c7 commit af7c992

File tree

3 files changed

+75
-2
lines changed

3 files changed

+75
-2
lines changed

source/change-streams/change-streams.rst

Lines changed: 11 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-10
13-
:Version: 1.12
12+
:Last Modified: 2022-03-14
13+
:Version: 1.13
1414

1515
.. contents::
1616

@@ -141,6 +141,13 @@ If an aggregate command with a ``$changeStream`` stage completes successfully, t
141141
*/
142142
ns: Document;
143143
144+
/**
145+
* Only present for ops of type 'rename'.
146+
*
147+
* The namespace, in the same format as `ns`, that a collection has been renamed to.
148+
*/
149+
to: Optional<Document>;
150+
144151
/**
145152
* Only present for ops of type ‘insert’, ‘update’, ‘replace’, and
146153
* ‘delete’.
@@ -923,3 +930,5 @@ Changelog
923930
| 2022-02-10 | Specified that ``getMore`` command must explicitly send |
924931
| | inherited ``comment``. |
925932
+------------+------------------------------------------------------------+
933+
| 2022-02-28 | Added ``to`` to ``ChangeStreamDocument``. |
934+
+------------+------------------------------------------------------------+

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,46 @@
426426
]
427427
}
428428
]
429+
},
430+
{
431+
"description": "to field is set in a rename change event",
432+
"runOnRequirements": [
433+
{
434+
"minServerVersion": "4.0.1"
435+
}
436+
],
437+
"operations": [
438+
{
439+
"name": "createChangeStream",
440+
"object": "collection0",
441+
"arguments": {
442+
"pipeline": []
443+
},
444+
"saveResultAsEntity": "changeStream0"
445+
},
446+
{
447+
"name": "rename",
448+
"object": "collection0",
449+
"arguments": {
450+
"to": "collection1"
451+
}
452+
},
453+
{
454+
"name": "iterateUntilDocumentOrError",
455+
"object": "changeStream0",
456+
"expectResult": {
457+
"operationType": "rename",
458+
"ns": {
459+
"db": "database0",
460+
"coll": "collection0"
461+
},
462+
"to": {
463+
"db": "database0",
464+
"coll": "collection1"
465+
}
466+
}
467+
}
468+
]
429469
}
430470
]
431471
}

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,27 @@ tests:
226226
comment: { $$exists: false }
227227
commandName: getMore
228228
databaseName: *database0
229+
230+
- description: "to field is set in a rename change event"
231+
runOnRequirements:
232+
- minServerVersion: "4.0.1"
233+
operations:
234+
- name: createChangeStream
235+
object: *collection0
236+
arguments:
237+
pipeline: []
238+
saveResultAsEntity: &changeStream0 changeStream0
239+
- name: rename
240+
object: *collection0
241+
arguments:
242+
to: &collection1 collection1
243+
- name: iterateUntilDocumentOrError
244+
object: *changeStream0
245+
expectResult:
246+
operationType: rename
247+
ns:
248+
db: *database0
249+
coll: *collection0
250+
to:
251+
db: *database0
252+
coll: *collection1

0 commit comments

Comments
 (0)