Skip to content

Commit 886cf65

Browse files
committed
PYTHON-1905 Don't send fullDocument field by default with every
$changeStream pipeline stage
1 parent 7425153 commit 886cf65

29 files changed

+98
-275
lines changed

pymongo/collection.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,7 +2405,7 @@ def aggregate_raw_batches(self, pipeline, **kwargs):
24052405
explicit_session=False,
24062406
**kwargs)
24072407

2408-
def watch(self, pipeline=None, full_document='default', resume_after=None,
2408+
def watch(self, pipeline=None, full_document=None, resume_after=None,
24092409
max_await_time_ms=None, batch_size=None, collation=None,
24102410
start_at_operation_time=None, session=None, start_after=None):
24112411
"""Watch changes on this collection.
@@ -2462,8 +2462,7 @@ def watch(self, pipeline=None, full_document='default', resume_after=None,
24622462
pipeline stages are valid after a ``$changeStream`` stage, see the
24632463
MongoDB documentation on change streams for the supported stages.
24642464
- `full_document` (optional): The fullDocument to pass as an option
2465-
to the ``$changeStream`` stage. Allowed values: 'default',
2466-
'updateLookup'. Defaults to 'default'.
2465+
to the ``$changeStream`` stage. Allowed values: 'updateLookup'.
24672466
When set to 'updateLookup', the change notification for partial
24682467
updates will include both a delta describing the changes to the
24692468
document, as well as a copy of the entire document that was

pymongo/database.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ def aggregate(self, pipeline, session=None, **kwargs):
513513
cmd.get_cursor, cmd.get_read_preference(s), s,
514514
retryable=not cmd._performs_write)
515515

516-
def watch(self, pipeline=None, full_document='default', resume_after=None,
516+
def watch(self, pipeline=None, full_document=None, resume_after=None,
517517
max_await_time_ms=None, batch_size=None, collation=None,
518518
start_at_operation_time=None, session=None, start_after=None):
519519
"""Watch changes on this database.
@@ -561,8 +561,7 @@ def watch(self, pipeline=None, full_document='default', resume_after=None,
561561
pipeline stages are valid after a ``$changeStream`` stage, see the
562562
MongoDB documentation on change streams for the supported stages.
563563
- `full_document` (optional): The fullDocument to pass as an option
564-
to the ``$changeStream`` stage. Allowed values: 'default',
565-
'updateLookup'. Defaults to 'default'.
564+
to the ``$changeStream`` stage. Allowed values: 'updateLookup'.
566565
When set to 'updateLookup', the change notification for partial
567566
updates will include both a delta describing the changes to the
568567
document, as well as a copy of the entire document that was

pymongo/mongo_client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ def _server_property(self, attr_name):
807807

808808
return getattr(server.description, attr_name)
809809

810-
def watch(self, pipeline=None, full_document='default', resume_after=None,
810+
def watch(self, pipeline=None, full_document=None, resume_after=None,
811811
max_await_time_ms=None, batch_size=None, collation=None,
812812
start_at_operation_time=None, session=None, start_after=None):
813813
"""Watch changes on this cluster.
@@ -855,8 +855,7 @@ def watch(self, pipeline=None, full_document='default', resume_after=None,
855855
pipeline stages are valid after a ``$changeStream`` stage, see the
856856
MongoDB documentation on change streams for the supported stages.
857857
- `full_document` (optional): The fullDocument to pass as an option
858-
to the ``$changeStream`` stage. Allowed values: 'default',
859-
'updateLookup'. Defaults to 'default'.
858+
to the ``$changeStream`` stage. Allowed values: 'updateLookup'.
860859
When set to 'updateLookup', the change notification for partial
861860
updates will include both a delta describing the changes to the
862861
document, as well as a copy of the entire document that was

test/change_streams/change-streams-errors.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@
5454
"cursor": {},
5555
"pipeline": [
5656
{
57-
"$changeStream": {
58-
"fullDocument": "default"
59-
}
57+
"$changeStream": {}
6058
},
6159
{
6260
"$unsupported": "foo"

test/change_streams/change-streams.json

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333
"cursor": {},
3434
"pipeline": [
3535
{
36-
"$changeStream": {
37-
"fullDocument": "default"
38-
}
36+
"$changeStream": {}
3937
}
4038
]
4139
},
@@ -153,9 +151,7 @@
153151
"cursor": {},
154152
"pipeline": [
155153
{
156-
"$changeStream": {
157-
"fullDocument": "default"
158-
}
154+
"$changeStream": {}
159155
}
160156
]
161157
},
@@ -226,9 +222,7 @@
226222
"cursor": {},
227223
"pipeline": [
228224
{
229-
"$changeStream": {
230-
"fullDocument": "default"
231-
}
225+
"$changeStream": {}
232226
},
233227
{
234228
"$match": {
@@ -312,9 +306,7 @@
312306
"cursor": {},
313307
"pipeline": [
314308
{
315-
"$changeStream": {
316-
"fullDocument": "default"
317-
}
309+
"$changeStream": {}
318310
}
319311
]
320312
},
@@ -404,7 +396,6 @@
404396
"pipeline": [
405397
{
406398
"$changeStream": {
407-
"fullDocument": "default",
408399
"allChangesForCluster": true
409400
}
410401
}
@@ -523,9 +514,7 @@
523514
"cursor": {},
524515
"pipeline": [
525516
{
526-
"$changeStream": {
527-
"fullDocument": "default"
528-
}
517+
"$changeStream": {}
529518
}
530519
]
531520
},
@@ -611,9 +600,7 @@
611600
"cursor": {},
612601
"pipeline": [
613602
{
614-
"$changeStream": {
615-
"fullDocument": "default"
616-
}
603+
"$changeStream": {}
617604
}
618605
]
619606
},
@@ -665,9 +652,7 @@
665652
"cursor": {},
666653
"pipeline": [
667654
{
668-
"$changeStream": {
669-
"fullDocument": "default"
670-
}
655+
"$changeStream": {}
671656
}
672657
]
673658
},
@@ -756,9 +741,7 @@
756741
},
757742
"pipeline": [
758743
{
759-
"$changeStream": {
760-
"fullDocument": "default"
761-
}
744+
"$changeStream": {}
762745
}
763746
]
764747
},

test/retryable_reads/aggregate-serverErrors.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
]
126126
},
127127
{
128-
"description": "Aggregate succeeds after InterruptedDueToStepDown",
128+
"description": "Aggregate succeeds after InterruptedDueToReplStateChange",
129129
"failPoint": {
130130
"configureFailPoint": "failCommand",
131131
"mode": {

test/retryable_reads/changeStreams-client.watch-serverErrors.json

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"pipeline": [
6060
{
6161
"$changeStream": {
62-
"fullDocument": "default",
6362
"allChangesForCluster": true
6463
}
6564
}
@@ -76,7 +75,6 @@
7675
"pipeline": [
7776
{
7877
"$changeStream": {
79-
"fullDocument": "default",
8078
"allChangesForCluster": true
8179
}
8280
}
@@ -88,7 +86,7 @@
8886
]
8987
},
9088
{
91-
"description": "client.watch succeeds after InterruptedDueToStepDown",
89+
"description": "client.watch succeeds after InterruptedDueToReplStateChange",
9290
"failPoint": {
9391
"configureFailPoint": "failCommand",
9492
"mode": {
@@ -116,7 +114,6 @@
116114
"pipeline": [
117115
{
118116
"$changeStream": {
119-
"fullDocument": "default",
120117
"allChangesForCluster": true
121118
}
122119
}
@@ -133,7 +130,6 @@
133130
"pipeline": [
134131
{
135132
"$changeStream": {
136-
"fullDocument": "default",
137133
"allChangesForCluster": true
138134
}
139135
}
@@ -173,7 +169,6 @@
173169
"pipeline": [
174170
{
175171
"$changeStream": {
176-
"fullDocument": "default",
177172
"allChangesForCluster": true
178173
}
179174
}
@@ -190,7 +185,6 @@
190185
"pipeline": [
191186
{
192187
"$changeStream": {
193-
"fullDocument": "default",
194188
"allChangesForCluster": true
195189
}
196190
}
@@ -230,7 +224,6 @@
230224
"pipeline": [
231225
{
232226
"$changeStream": {
233-
"fullDocument": "default",
234227
"allChangesForCluster": true
235228
}
236229
}
@@ -247,7 +240,6 @@
247240
"pipeline": [
248241
{
249242
"$changeStream": {
250-
"fullDocument": "default",
251243
"allChangesForCluster": true
252244
}
253245
}
@@ -287,7 +279,6 @@
287279
"pipeline": [
288280
{
289281
"$changeStream": {
290-
"fullDocument": "default",
291282
"allChangesForCluster": true
292283
}
293284
}
@@ -304,7 +295,6 @@
304295
"pipeline": [
305296
{
306297
"$changeStream": {
307-
"fullDocument": "default",
308298
"allChangesForCluster": true
309299
}
310300
}
@@ -344,7 +334,6 @@
344334
"pipeline": [
345335
{
346336
"$changeStream": {
347-
"fullDocument": "default",
348337
"allChangesForCluster": true
349338
}
350339
}
@@ -361,7 +350,6 @@
361350
"pipeline": [
362351
{
363352
"$changeStream": {
364-
"fullDocument": "default",
365353
"allChangesForCluster": true
366354
}
367355
}
@@ -401,7 +389,6 @@
401389
"pipeline": [
402390
{
403391
"$changeStream": {
404-
"fullDocument": "default",
405392
"allChangesForCluster": true
406393
}
407394
}
@@ -418,7 +405,6 @@
418405
"pipeline": [
419406
{
420407
"$changeStream": {
421-
"fullDocument": "default",
422408
"allChangesForCluster": true
423409
}
424410
}
@@ -458,7 +444,6 @@
458444
"pipeline": [
459445
{
460446
"$changeStream": {
461-
"fullDocument": "default",
462447
"allChangesForCluster": true
463448
}
464449
}
@@ -475,7 +460,6 @@
475460
"pipeline": [
476461
{
477462
"$changeStream": {
478-
"fullDocument": "default",
479463
"allChangesForCluster": true
480464
}
481465
}
@@ -515,7 +499,6 @@
515499
"pipeline": [
516500
{
517501
"$changeStream": {
518-
"fullDocument": "default",
519502
"allChangesForCluster": true
520503
}
521504
}
@@ -532,7 +515,6 @@
532515
"pipeline": [
533516
{
534517
"$changeStream": {
535-
"fullDocument": "default",
536518
"allChangesForCluster": true
537519
}
538520
}
@@ -572,7 +554,6 @@
572554
"pipeline": [
573555
{
574556
"$changeStream": {
575-
"fullDocument": "default",
576557
"allChangesForCluster": true
577558
}
578559
}
@@ -589,7 +570,6 @@
589570
"pipeline": [
590571
{
591572
"$changeStream": {
592-
"fullDocument": "default",
593573
"allChangesForCluster": true
594574
}
595575
}
@@ -629,7 +609,6 @@
629609
"pipeline": [
630610
{
631611
"$changeStream": {
632-
"fullDocument": "default",
633612
"allChangesForCluster": true
634613
}
635614
}
@@ -646,7 +625,6 @@
646625
"pipeline": [
647626
{
648627
"$changeStream": {
649-
"fullDocument": "default",
650628
"allChangesForCluster": true
651629
}
652630
}
@@ -687,7 +665,6 @@
687665
"pipeline": [
688666
{
689667
"$changeStream": {
690-
"fullDocument": "default",
691668
"allChangesForCluster": true
692669
}
693670
}
@@ -704,7 +681,6 @@
704681
"pipeline": [
705682
{
706683
"$changeStream": {
707-
"fullDocument": "default",
708684
"allChangesForCluster": true
709685
}
710686
}
@@ -748,7 +724,6 @@
748724
"pipeline": [
749725
{
750726
"$changeStream": {
751-
"fullDocument": "default",
752727
"allChangesForCluster": true
753728
}
754729
}

0 commit comments

Comments
 (0)