Skip to content

Commit

Permalink
GODRIVER-2979 Rename SingleResult DecodeBytes to Raw (#1414)
Browse files Browse the repository at this point in the history
Co-authored-by: Steven Silvester <steven.silvester@ieee.org>
  • Loading branch information
prestonvasquez and blink1073 authored Oct 9, 2023
1 parent 9ca46ea commit 39d0411
Show file tree
Hide file tree
Showing 18 changed files with 86 additions and 85 deletions.
2 changes: 1 addition & 1 deletion mongo/client_side_encryption_examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func Example_clientSideEncryption() {
if err != nil {
log.Fatalf("InsertOne error: %v", err)
}
res, err := collection.FindOne(context.TODO(), bson.D{}).DecodeBytes()
res, err := collection.FindOne(context.TODO(), bson.D{}).Raw()
if err != nil {
log.Fatalf("FindOne error: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion mongo/gridfs/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ func (b *Bucket) createIndexes(ctx context.Context) error {

docRes := cloned.FindOne(ctx, bson.D{}, options.FindOne().SetProjection(bson.D{{"_id", 1}}))

_, err = docRes.DecodeBytes()
_, err = docRes.Raw()
if err != mongo.ErrNoDocuments {
// nil, or error that occurred during the FindOne operation
return err
Expand Down
22 changes: 11 additions & 11 deletions mongo/integration/client_side_encryption_prose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
// document from the collection.
coll := cse.kvClient.Database(kvDatabase).Collection(dkCollection)

keydoc, err := coll.FindOne(context.Background(), bson.D{}).DecodeBytes()
keydoc, err := coll.FindOne(context.Background(), bson.D{}).Raw()
assert.Nil(mt, err, "error in decoding bytes: %v", err)

// Remove the key document from the collection.
Expand Down Expand Up @@ -299,7 +299,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
assert.Nil(mt, err, "InsertOne error: %v", err)

// find the inserted document. the value should be decrypted automatically
resBytes, err := cpt.cseColl.FindOne(context.Background(), bson.D{{"_id", tc.provider}}).DecodeBytes()
resBytes, err := cpt.cseColl.FindOne(context.Background(), bson.D{{"_id", tc.provider}}).Raw()
assert.Nil(mt, err, "Find error: %v", err)
foundVal := resBytes.Lookup("value").StringValue()
assert.Equal(mt, valueToEncrypt, foundVal, "expected value %v, got %v", valueToEncrypt, foundVal)
Expand Down Expand Up @@ -697,13 +697,13 @@ func TestClientSideEncryptionProse(t *testing.T) {
assert.Nil(mt, err, "InsertOne error for corpus document: %v", err)

// find document using client with encryption and assert it matches original
decryptedDoc, err := cpt.cseColl.FindOne(context.Background(), bson.D{}).DecodeBytes()
decryptedDoc, err := cpt.cseColl.FindOne(context.Background(), bson.D{}).Raw()
assert.Nil(mt, err, "Find error with encrypted client: %v", err)
assert.Equal(mt, corpus, decryptedDoc, "expected document %v, got %v", corpus, decryptedDoc)

// find document using a client without encryption enabled and assert fields remain encrypted
corpusEncrypted := readJSONFile(mt, "corpus-encrypted.json")
foundDoc, err := cpt.coll.FindOne(context.Background(), bson.D{}).DecodeBytes()
foundDoc, err := cpt.coll.FindOne(context.Background(), bson.D{}).Raw()
assert.Nil(mt, err, "Find error with unencrypted client: %v", err)

encryptedElems, _ := corpusEncrypted.Elements()
Expand Down Expand Up @@ -1376,7 +1376,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
}
assert.Nil(mt, err, "InsertOne error: %v", err)

raw, err := coll.FindOne(context.Background(), bson.M{"_id": 0}).DecodeBytes()
raw, err := coll.FindOne(context.Background(), bson.M{"_id": 0}).Raw()
assert.Nil(mt, err, "FindOne error: %v", err)

expected := bsoncore.NewDocumentBuilder().
Expand Down Expand Up @@ -1727,8 +1727,8 @@ func TestClientSideEncryptionProse(t *testing.T) {
// Find.
res := coll.FindOne(context.Background(), bson.D{{"encryptedIndexed", findPayload}})
assert.Nil(mt, res.Err(), "Error in FindOne: %v", res.Err())
got, err := res.DecodeBytes()
assert.Nil(mt, err, "error in DecodeBytes: %v", err)
got, err := res.Raw()
assert.Nil(mt, err, "error in Raw: %v", err)
gotValue, err := got.LookupErr("encryptedIndexed")
assert.Nil(mt, err, "error in LookupErr: %v", err)
assert.Equal(mt, gotValue.StringValue(), valueToEncrypt, "expected %q, got %q", valueToEncrypt, gotValue.StringValue())
Expand Down Expand Up @@ -1808,8 +1808,8 @@ func TestClientSideEncryptionProse(t *testing.T) {
// Find.
res := coll.FindOne(context.Background(), bson.D{{"_id", 1}})
assert.Nil(mt, res.Err(), "Error in FindOne: %v", res.Err())
got, err := res.DecodeBytes()
assert.Nil(mt, err, "error in DecodeBytes: %v", err)
got, err := res.Raw()
assert.Nil(mt, err, "error in Raw: %v", err)
gotValue, err := got.LookupErr("encryptedUnindexed")
assert.Nil(mt, err, "error in LookupErr: %v", err)
assert.Equal(mt, gotValue.StringValue(), valueToEncrypt, "expected %q, got %q", valueToEncrypt, gotValue.StringValue())
Expand Down Expand Up @@ -1899,15 +1899,15 @@ func TestClientSideEncryptionProse(t *testing.T) {
var validateAddKeyAltName = func(mt *mtest.T, cse *cseProseTest, res *mongo.SingleResult, expected ...string) {
assert.Nil(mt, res.Err(), "error adding key alt name: %v", res.Err())

resbytes, err := res.DecodeBytes()
resbytes, err := res.Raw()
assert.Nil(mt, err, "error decoding result bytes: %v", err)

idsubtype, iddata := bson.RawValue{Type: bsontype.EmbeddedDocument, Value: resbytes}.
Document().Lookup("_id").Binary()
filter := bsoncore.NewDocumentBuilder().AppendBinary("_id", idsubtype, iddata).Build()

ctx := context.Background()
updatedData, err := cse.keyVaultColl.FindOne(ctx, filter).DecodeBytes()
updatedData, err := cse.keyVaultColl.FindOne(ctx, filter).Raw()
assert.Nil(mt, err, "error decoding result bytes: %v", err)

updated := bson.RawValue{Type: bsontype.EmbeddedDocument, Value: updatedData}
Expand Down
8 changes: 4 additions & 4 deletions mongo/integration/client_side_encryption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ func TestClientSideEncryptionCustomCrypt(t *testing.T) {
res := coll.FindOne(context.Background(), bson.D{{"foo", "bar"}})
assert.Nil(mt, res.Err(), "FindOne error: %v", err)

rawRes, err := res.DecodeBytes()
assert.Nil(mt, err, "DecodeBytes error: %v", err)
rawRes, err := res.Raw()
assert.Nil(mt, err, "Raw error: %v", err)
ssn, ok := rawRes.Lookup("ssn").StringValueOK()
assert.True(mt, ok, "expected 'ssn' value to be type string, got %T", ssn)
assert.Equal(mt, ssn, mySSN, "expected 'ssn' value %q, got %q", mySSN, ssn)
Expand Down Expand Up @@ -587,8 +587,8 @@ func TestFLE2DocsExample(t *testing.T) {
unencryptedColl := mt.Client.Database("docsExamples").Collection("encrypted")
res := unencryptedColl.FindOne(context.Background(), bson.M{"_id": 1})
assert.Nil(mt, res.Err(), "error in FindOne: %v", res.Err())
resBSON, err := res.DecodeBytes()
assert.Nil(mt, err, "error in DecodeBytes: %v", err)
resBSON, err := res.Raw()
assert.Nil(mt, err, "error in Raw: %v", err)

val := resBSON.Lookup("encryptedIndexed")
assert.Equal(mt, val.Type, bsontype.Binary, "expected encryptedIndexed to be Binary, got %v", val.Type)
Expand Down
6 changes: 3 additions & 3 deletions mongo/integration/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func TestClient(t *testing.T) {

rdr, err := authClient.Database("test").RunCommand(context.Background(), bson.D{
{"connectionStatus", 1},
}).DecodeBytes()
}).Raw()
assert.Nil(mt, err, "connectionStatus error: %v", err)
users, err := rdr.LookupErr("authInfo", "authenticatedUsers")
assert.Nil(mt, err, "authenticatedUsers not found in response")
Expand Down Expand Up @@ -878,8 +878,8 @@ func TestClient_BSONOptions(t *testing.T) {
}

if tc.wantRaw != nil {
got, err := sr.DecodeBytes()
require.NoError(mt, err, "DecodeBytes error")
got, err := sr.Raw()
require.NoError(mt, err, "Raw error")

assert.EqualBSON(mt, tc.wantRaw, got)
}
Expand Down
18 changes: 9 additions & 9 deletions mongo/integration/collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ func TestCollection(t *testing.T) {
})
mt.Run("found", func(mt *mtest.T) {
initCollection(mt, mt.Coll)
res, err := mt.Coll.FindOne(context.Background(), bson.D{{"x", 1}}).DecodeBytes()
res, err := mt.Coll.FindOne(context.Background(), bson.D{{"x", 1}}).Raw()
assert.Nil(mt, err, "FindOne error: %v", err)

x, err := res.LookupErr("x")
Expand Down Expand Up @@ -1150,7 +1150,7 @@ func TestCollection(t *testing.T) {
SetShowRecordID(false).
SetSkip(0).
SetSort(bson.D{{"x", int32(1)}})
res, err := mt.Coll.FindOne(context.Background(), bson.D{}, opts).DecodeBytes()
res, err := mt.Coll.FindOne(context.Background(), bson.D{}, opts).Raw()
assert.Nil(mt, err, "FindOne error: %v", err)

x, err := res.LookupErr("x")
Expand Down Expand Up @@ -1210,7 +1210,7 @@ func TestCollection(t *testing.T) {
})
assert.Nil(mt, err, "CreateOne error: %v", err)

res, err := mt.Coll.FindOne(context.Background(), bson.D{{"x", 1}}, tc.opts).DecodeBytes()
res, err := mt.Coll.FindOne(context.Background(), bson.D{{"x", 1}}, tc.opts).Raw()

if tc.errParam != "" {
expErr := mongo.ErrMapForOrderedArgument{tc.errParam}
Expand All @@ -1231,7 +1231,7 @@ func TestCollection(t *testing.T) {
mt.RunOpts("find one and delete", noClientOpts, func(mt *mtest.T) {
mt.Run("found", func(mt *mtest.T) {
initCollection(mt, mt.Coll)
res, err := mt.Coll.FindOneAndDelete(context.Background(), bson.D{{"x", 3}}).DecodeBytes()
res, err := mt.Coll.FindOneAndDelete(context.Background(), bson.D{{"x", 3}}).Raw()
assert.Nil(mt, err, "FindOneAndDelete error: %v", err)

elem, err := res.LookupErr("x")
Expand Down Expand Up @@ -1270,7 +1270,7 @@ func TestCollection(t *testing.T) {
})
assert.Nil(mt, err, "CreateOne error: %v", err)

res, err := mt.Coll.FindOneAndDelete(context.Background(), bson.D{{"x", 1}}, tc.opts).DecodeBytes()
res, err := mt.Coll.FindOneAndDelete(context.Background(), bson.D{{"x", 1}}, tc.opts).Raw()

if tc.errParam != "" {
expErr := mongo.ErrMapForOrderedArgument{tc.errParam}
Expand Down Expand Up @@ -1302,7 +1302,7 @@ func TestCollection(t *testing.T) {
filter := bson.D{{"x", 3}}
replacement := bson.D{{"y", 3}}

res, err := mt.Coll.FindOneAndReplace(context.Background(), filter, replacement).DecodeBytes()
res, err := mt.Coll.FindOneAndReplace(context.Background(), filter, replacement).Raw()
assert.Nil(mt, err, "FindOneAndReplace error: %v", err)
elem, err := res.LookupErr("x")
assert.Nil(mt, err, "x not found in result %v", res)
Expand Down Expand Up @@ -1346,7 +1346,7 @@ func TestCollection(t *testing.T) {
})
assert.Nil(mt, err, "CreateOne error: %v", err)

res, err := mt.Coll.FindOneAndReplace(context.Background(), bson.D{{"x", 1}}, bson.D{{"y", 3}}, tc.opts).DecodeBytes()
res, err := mt.Coll.FindOneAndReplace(context.Background(), bson.D{{"x", 1}}, bson.D{{"y", 3}}, tc.opts).Raw()

if tc.errParam != "" {
expErr := mongo.ErrMapForOrderedArgument{tc.errParam}
Expand Down Expand Up @@ -1380,7 +1380,7 @@ func TestCollection(t *testing.T) {
filter := bson.D{{"x", 3}}
update := bson.D{{"$set", bson.D{{"x", 6}}}}

res, err := mt.Coll.FindOneAndUpdate(context.Background(), filter, update).DecodeBytes()
res, err := mt.Coll.FindOneAndUpdate(context.Background(), filter, update).Raw()
assert.Nil(mt, err, "FindOneAndUpdate error: %v", err)
elem, err := res.LookupErr("x")
assert.Nil(mt, err, "x not found in result %v", res)
Expand Down Expand Up @@ -1428,7 +1428,7 @@ func TestCollection(t *testing.T) {
})
assert.Nil(mt, err, "CreateOne error: %v", err)

res, err := mt.Coll.FindOneAndUpdate(context.Background(), bson.D{{"x", 1}}, bson.D{{"$set", bson.D{{"x", 6}}}}, tc.opts).DecodeBytes()
res, err := mt.Coll.FindOneAndUpdate(context.Background(), bson.D{{"x", 1}}, bson.D{{"$set", bson.D{{"x", 6}}}}, tc.opts).Raw()

if tc.errParam != "" {
expErr := mongo.ErrMapForOrderedArgument{tc.errParam}
Expand Down
2 changes: 1 addition & 1 deletion mongo/integration/crud_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ func verifySingleResult(mt *mtest.T, actualResult *mongo.SingleResult, expectedR
}

expected := expectedResult.(bson.Raw)
actual, _ := actualResult.DecodeBytes()
actual, _ := actualResult.Raw()
if err := compareDocs(mt, expected, actual); err != nil {
mt.Fatalf("SingleResult document mismatch: %s", err)
}
Expand Down
4 changes: 2 additions & 2 deletions mongo/integration/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestDatabase(t *testing.T) {

mt.RunOpts("run command", noClientOpts, func(mt *mtest.T) {
mt.Run("decode raw", func(mt *mtest.T) {
res, err := mt.DB.RunCommand(context.Background(), bson.D{{handshake.LegacyHello, 1}}).DecodeBytes()
res, err := mt.DB.RunCommand(context.Background(), bson.D{{handshake.LegacyHello, 1}}).Raw()
assert.Nil(mt, err, "RunCommand error: %v", err)

ok, err := res.LookupErr("ok")
Expand Down Expand Up @@ -105,7 +105,7 @@ func TestDatabase(t *testing.T) {
{"insert", "test"},
{"documents", bson.A{bson.D{{"a", 1}}}},
}
res, gotErr := mt.DB.RunCommand(context.Background(), cmd).DecodeBytes()
res, gotErr := mt.DB.RunCommand(context.Background(), cmd).Raw()

n, ok := res.Lookup("n").Int32OK()
assert.True(mt, ok, "expected n in response")
Expand Down
2 changes: 1 addition & 1 deletion mongo/integration/gridfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func TestGridFS(x *testing.T) {
// The uploadDate field is calculated when the upload is complete. Manually fetch it from the
// fs.files collection to use in assertions.
filesColl := mt.DB.Collection("fs.files")
uploadedFileDoc, err := filesColl.FindOne(context.Background(), bson.D{}).DecodeBytes()
uploadedFileDoc, err := filesColl.FindOne(context.Background(), bson.D{}).Raw()
assert.Nil(mt, err, "FindOne error: %v", err)
uploadTime := uploadedFileDoc.Lookup("uploadDate").Time().UTC()

Expand Down
4 changes: 2 additions & 2 deletions mongo/integration/mtest/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func Setup(setupOpts ...*SetupOptions) error {

testContext.authEnabled = os.Getenv("AUTH") == "auth"
testContext.sslEnabled = os.Getenv("SSL") == "ssl"
biRes, err := testContext.client.Database("admin").RunCommand(context.Background(), bson.D{{"buildInfo", 1}}).DecodeBytes()
biRes, err := testContext.client.Database("admin").RunCommand(context.Background(), bson.D{{"buildInfo", 1}}).Raw()
if err != nil {
return fmt.Errorf("buildInfo error: %v", err)
}
Expand All @@ -215,7 +215,7 @@ func Setup(setupOpts ...*SetupOptions) error {
// Get server parameters if test is not running against ADL; ADL does not have "getParameter" command.
if !testContext.dataLake {
db := testContext.client.Database("admin")
testContext.serverParameters, err = db.RunCommand(context.Background(), bson.D{{"getParameter", "*"}}).DecodeBytes()
testContext.serverParameters, err = db.RunCommand(context.Background(), bson.D{{"getParameter", "*"}}).Raw()
if err != nil {
return fmt.Errorf("error getting serverParameters: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion mongo/integration/retryable_writes_prose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestRetryableWritesProse(t *testing.T) {
})
errorOpts := mtest.NewOptions().Topologies(mtest.ReplicaSet, mtest.Sharded)
mt.RunOpts("wrap mmapv1 error", errorOpts, func(mt *mtest.T) {
res, err := mt.DB.RunCommand(context.Background(), bson.D{{"serverStatus", 1}}).DecodeBytes()
res, err := mt.DB.RunCommand(context.Background(), bson.D{{"serverStatus", 1}}).Raw()
assert.Nil(mt, err, "serverStatus error: %v", err)
storageEngine, ok := res.Lookup("storageEngine", "name").StringValueOK()
if !ok || storageEngine != "mmapv1" {
Expand Down
24 changes: 12 additions & 12 deletions mongo/integration/unified/client_encryption_operation_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ func executeAddKeyAltName(ctx context.Context, operation *operation) (*operation
}
}

res, err := cee.AddKeyAltName(ctx, id, keyAltName).DecodeBytes()
// Ignore ErrNoDocuments errors from DecodeBytes. In the event that the cursor returned in a find operation has no
// associated documents, DecodeBytes will return ErrNoDocuments.
res, err := cee.AddKeyAltName(ctx, id, keyAltName).Raw()
// Ignore ErrNoDocuments errors from Raw. In the event that the cursor returned in a find operation has no
// associated documents, Raw will return ErrNoDocuments.
if err == mongo.ErrNoDocuments {
err = nil
}
Expand Down Expand Up @@ -199,9 +199,9 @@ func executeGetKeyByAltName(ctx context.Context, operation *operation) (*operati
}
}

res, err := cee.GetKeyByAltName(ctx, keyAltName).DecodeBytes()
// Ignore ErrNoDocuments errors from DecodeBytes. In the event that the cursor returned in a find operation has no
// associated documents, DecodeBytes will return ErrNoDocuments.
res, err := cee.GetKeyByAltName(ctx, keyAltName).Raw()
// Ignore ErrNoDocuments errors from Raw. In the event that the cursor returned in a find operation has no
// associated documents, Raw will return ErrNoDocuments.
if err == mongo.ErrNoDocuments {
err = nil
}
Expand Down Expand Up @@ -235,9 +235,9 @@ func executeGetKey(ctx context.Context, operation *operation) (*operationResult,
}
}

res, err := cee.GetKey(ctx, id).DecodeBytes()
// Ignore ErrNoDocuments errors from DecodeBytes. In the event that the cursor returned in a find operation has no
// associated documents, DecodeBytes will return ErrNoDocuments.
res, err := cee.GetKey(ctx, id).Raw()
// Ignore ErrNoDocuments errors from Raw. In the event that the cursor returned in a find operation has no
// associated documents, Raw will return ErrNoDocuments.
if err == mongo.ErrNoDocuments {
err = nil
}
Expand Down Expand Up @@ -291,9 +291,9 @@ func executeRemoveKeyAltName(ctx context.Context, operation *operation) (*operat
}
}

res, err := cee.RemoveKeyAltName(ctx, id, keyAltName).DecodeBytes()
// Ignore ErrNoDocuments errors from DecodeBytes. In the event that the cursor returned in a find operation has no
// associated documents, DecodeBytes will return ErrNoDocuments.
res, err := cee.RemoveKeyAltName(ctx, id, keyAltName).Raw()
// Ignore ErrNoDocuments errors from Raw. In the event that the cursor returned in a find operation has no
// associated documents, Raw will return ErrNoDocuments.
if err == mongo.ErrNoDocuments {
err = nil
}
Expand Down
26 changes: 13 additions & 13 deletions mongo/integration/unified/collection_operation_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,9 @@ func executeFindOne(ctx context.Context, operation *operation) (*operationResult
return nil, newMissingArgumentError("filter")
}

res, err := coll.FindOne(ctx, filter, opts).DecodeBytes()
// Ignore ErrNoDocuments errors from DecodeBytes. In the event that the cursor
// returned in a find operation has no associated documents, DecodeBytes will
res, err := coll.FindOne(ctx, filter, opts).Raw()
// Ignore ErrNoDocuments errors from Raw. In the event that the cursor
// returned in a find operation has no associated documents, Raw will
// return ErrNoDocuments.
if err == mongo.ErrNoDocuments {
err = nil
Expand Down Expand Up @@ -813,9 +813,9 @@ func executeFindOneAndDelete(ctx context.Context, operation *operation) (*operat
return nil, newMissingArgumentError("filter")
}

res, err := coll.FindOneAndDelete(ctx, filter, opts).DecodeBytes()
// Ignore ErrNoDocuments errors from DecodeBytes. In the event that the cursor
// returned in a find operation has no associated documents, DecodeBytes will
res, err := coll.FindOneAndDelete(ctx, filter, opts).Raw()
// Ignore ErrNoDocuments errors from Raw. In the event that the cursor
// returned in a find operation has no associated documents, Raw will
// return ErrNoDocuments.
if err == mongo.ErrNoDocuments {
err = nil
Expand Down Expand Up @@ -893,9 +893,9 @@ func executeFindOneAndReplace(ctx context.Context, operation *operation) (*opera
return nil, newMissingArgumentError("replacement")
}

res, err := coll.FindOneAndReplace(ctx, filter, replacement, opts).DecodeBytes()
// Ignore ErrNoDocuments errors from DecodeBytes. In the event that the cursor
// returned in a find operation has no associated documents, DecodeBytes will
res, err := coll.FindOneAndReplace(ctx, filter, replacement, opts).Raw()
// Ignore ErrNoDocuments errors from Raw. In the event that the cursor
// returned in a find operation has no associated documents, Raw will
// return ErrNoDocuments.
if err == mongo.ErrNoDocuments {
err = nil
Expand Down Expand Up @@ -980,9 +980,9 @@ func executeFindOneAndUpdate(ctx context.Context, operation *operation) (*operat
return nil, newMissingArgumentError("update")
}

res, err := coll.FindOneAndUpdate(ctx, filter, update, opts).DecodeBytes()
// Ignore ErrNoDocuments errors from DecodeBytes. In the event that the cursor
// returned in a find operation has no associated documents, DecodeBytes will
res, err := coll.FindOneAndUpdate(ctx, filter, update, opts).Raw()
// Ignore ErrNoDocuments errors from Raw. In the event that the cursor
// returned in a find operation has no associated documents, Raw will
// return ErrNoDocuments.
if err == mongo.ErrNoDocuments {
err = nil
Expand Down Expand Up @@ -1202,7 +1202,7 @@ func executeRenameCollection(ctx context.Context, operation *operation) (*operat
}
// rename can only be run on the 'admin' database.
admin := coll.Database().Client().Database("admin")
res, err := admin.RunCommand(context.Background(), renameCmd).DecodeBytes()
res, err := admin.RunCommand(context.Background(), renameCmd).Raw()
return newDocumentResult(res, err), nil
}

Expand Down
Loading

0 comments on commit 39d0411

Please sign in to comment.