Skip to content

Commit

Permalink
Merge branch 'master' into support-psql-primary-key-overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 authored Aug 29, 2024
2 parents 9dd64bc + aeb25f4 commit 4746365
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/mongo/change_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,17 @@ func NewChangeEvent(rawChangeEvent bson.M) (*ChangeEvent, error) {

fullDocumentBeforeChange, isOk := rawChangeEvent["fullDocumentBeforeChange"]
if isOk {
castedFullDocumentBeforeChange, isOk := fullDocumentBeforeChange.(bson.M)
if !isOk {
return nil, fmt.Errorf("expected fullDocumentBeforeChange to be bson.M, got: %T", fullDocumentBeforeChange)
switch castedFullDoc := fullDocumentBeforeChange.(type) {
case bson.M:
changeEvent.fullDocumentBeforeChange = &castedFullDoc
case nil:
// This may happen if the row was purged before we can read it
changeEvent.fullDocumentBeforeChange = &bson.M{
"_id": objectID,
}
default:
return nil, fmt.Errorf("expected fullDocumentBeforeChange to be bson.M or nil, got: %T", fullDoc)
}

changeEvent.fullDocumentBeforeChange = &castedFullDocumentBeforeChange
}

return changeEvent, nil
Expand Down

0 comments on commit 4746365

Please sign in to comment.