Skip to content

Commit d7043e1

Browse files
kpatel71716Divjot Aroraiwysiumengskysamacvluca
authored andcommitted
REALMC-5872 merging topology changes to v1.4.1 driver (#1)
* Update version to v1.3.1+prerelease * Change w value for unsatisfiable write concern in tests (mongodb#301) - Addresses test failures that started after by SERVER-45920 * GODRIVER-895 check if strLength is 0 in ReadCodeWithScope (mongodb#311) * GODRIVER-1487 fix adding UnknownTransactionCommitResult (mongodb#307) * GODRIVER-1488 turn off DecodeDeepZeroInline for mgocompat.Registry (mongodb#312) * Fix primitive.Regex Equal method (mongodb#318) * GODRIVER-1507 Correctly pass URI to topology (mongodb#320) * Update version to 1.3.1 * Update version to v1.3.2+prerelease * GODRIVER-1522 Ignore read preference for aggregations with output stages (mongodb#327) * GODRIVER-1520 Fix panics for lone scope (mongodb#331) * GODRIVER-1532 Remove check when decoding invalid UTF-8 strings (mongodb#333) * Fix typo in objectid.go (mongodb#335) * GODRIVER-1502 Fix variable shadowing in parsing (mongodb#332) * GODRIVER-1506 Fix error checking for invalid extjson timestamp values (mongodb#337) * GODRIVER-1504 Restrict top-level keys from being parsed as extjson (mongodb#340) * GODRIVER-1513 Disallow escaped single quotes in extjson keys (mongodb#342) * GODRIVER-1535 Fix session IDs batching in Disconnect * GODRIVER-1540 fix deadlock in connection (mongodb#348) * GODRIVER-1549 Select all servers when an empty tag set is given (mongodb#352) * GODRIVER-1431 Add explicit encryption examples (mongodb#350) * Update version to v1.3.2 * STITCH-4296: Export contextWithSession * STITCH-4296: Export sessionFromContext * STITCH-4680 - expose topology consistency * STITCH-4841: Add FullDocumentBeforeChange option to Mongo-go-driver * GODRIVER-672 Change session IDs to be stored as bson.Raw (mongodb#339) (cherry picked from commit d080bd0) * do not leak cancelConnectContext * REALMC-5872 renaming NewSessionContext to ContextWithSession * REALMC-5872 adding back size check in pool test * REALMC-5872 removing unused IsConsistent topology function and renaming changed vars Co-authored-by: Divjot Arora <[email protected]> Co-authored-by: iwysiu <[email protected]> Co-authored-by: mengskysama <[email protected]> Co-authored-by: Luca(Wei) Chen <[email protected]> Co-authored-by: Haley Owen <[email protected]> Co-authored-by: Eric Daniels <[email protected]> Co-authored-by: Tyler Kaye <[email protected]> Co-authored-by: Jonathan Reams <[email protected]> Co-authored-by: mike o'brien <[email protected]> (cherry picked from commit c59bda0)
1 parent 40c0e70 commit d7043e1

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

mongo/change_stream.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,14 @@ func (cs *ChangeStream) createPipelineOptionsDoc() bsoncore.Document {
365365
plDoc = bsoncore.AppendStringElement(plDoc, "fullDocument", string(*cs.options.FullDocument))
366366
}
367367

368+
if cs.options.FullDocumentBeforeChange != nil {
369+
plDoc = bsoncore.AppendStringElement(
370+
plDoc,
371+
"fullDocumentBeforeChange",
372+
string(*cs.options.FullDocumentBeforeChange),
373+
)
374+
}
375+
368376
if cs.options.ResumeAfter != nil {
369377
var raDoc bsoncore.Document
370378
raDoc, cs.err = transformBsoncoreDocument(cs.registry, cs.options.ResumeAfter, true, "resumeAfter")

mongo/options/changestreamoptions.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ type ChangeStreamOptions struct {
2727
// the updated document will not be included in the change notification.
2828
FullDocument *FullDocument
2929

30+
// When set to ‘whenAvailable’ or ‘required’ will have both the delta and the full document before the change was applied
31+
FullDocumentBeforeChange *FullDocumentBeforeChange
32+
3033
// The maximum amount of time that the server should wait for new documents to satisfy a tailable cursor query.
3134
MaxAwaitTime *time.Duration
3235

@@ -79,6 +82,12 @@ func (cso *ChangeStreamOptions) SetMaxAwaitTime(d time.Duration) *ChangeStreamOp
7982
return cso
8083
}
8184

85+
// SetFullDocumentBeforeChange sets the value for the FullDocumentBeforeChange field.
86+
func (cso *ChangeStreamOptions) SetFullDocumentBeforeChange(fdbc FullDocumentBeforeChange) *ChangeStreamOptions {
87+
cso.FullDocumentBeforeChange = &fdbc
88+
return cso
89+
}
90+
8291
// SetResumeAfter sets the value for the ResumeAfter field.
8392
func (cso *ChangeStreamOptions) SetResumeAfter(rt interface{}) *ChangeStreamOptions {
8493
cso.ResumeAfter = rt
@@ -114,6 +123,9 @@ func MergeChangeStreamOptions(opts ...*ChangeStreamOptions) *ChangeStreamOptions
114123
if cso.FullDocument != nil {
115124
csOpts.FullDocument = cso.FullDocument
116125
}
126+
if cso.FullDocumentBeforeChange != nil {
127+
csOpts.FullDocumentBeforeChange = cso.FullDocumentBeforeChange
128+
}
117129
if cso.MaxAwaitTime != nil {
118130
csOpts.MaxAwaitTime = cso.MaxAwaitTime
119131
}

mongo/options/mongooptions.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,23 @@ const (
101101
UpdateLookup FullDocument = "updateLookup"
102102
)
103103

104+
// FullDocumentBeforeChange specifies whether a change stream should include a copy of the entire document that was changed from
105+
// the time at which the update is applied
106+
type FullDocumentBeforeChange string
107+
108+
const (
109+
// Default / off does not include a document copy
110+
FullDocumentBeforeChangeOff FullDocumentBeforeChange = "off"
111+
112+
// whenAvailable includes a delta describing the changes to the document and a copy of the entire document that
113+
// was changed when it is available
114+
FullDocumentBeforeChangeWhenAvailable FullDocumentBeforeChange = "whenAvailable"
115+
116+
// required includes a delta describing the changes to the document and a copy of the entire document that
117+
// was changed
118+
FullDocumentBeforeChangeRequired FullDocumentBeforeChange = "required"
119+
)
120+
104121
// ArrayFilters is used to hold filters for the array filters CRUD option. If a registry is nil, bson.DefaultRegistry
105122
// will be used when converting the filter interfaces to BSON.
106123
type ArrayFilters struct {

0 commit comments

Comments
 (0)