Skip to content

Commit da5f54a

Browse files
GODRIVER-2979 Rename SingleResult DecodeBytes to Raw (#1395)
Co-authored-by: Steven Silvester <[email protected]>
1 parent 79b22ea commit da5f54a

18 files changed

+95
-85
lines changed

mongo/client_side_encryption_examples_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func Example_clientSideEncryption() {
6060
if err != nil {
6161
log.Fatalf("InsertOne error: %v", err)
6262
}
63-
res, err := collection.FindOne(context.TODO(), bson.D{}).DecodeBytes()
63+
res, err := collection.FindOne(context.TODO(), bson.D{}).Raw()
6464
if err != nil {
6565
log.Fatalf("FindOne error: %v", err)
6666
}

mongo/gridfs/bucket.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ func (b *Bucket) createIndexes(ctx context.Context) error {
593593

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

596-
_, err = docRes.DecodeBytes()
596+
_, err = docRes.Raw()
597597
if err != mongo.ErrNoDocuments {
598598
// nil, or error that occurred during the FindOne operation
599599
return err

mongo/integration/client_side_encryption_prose_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
124124
// document from the collection.
125125
coll := cse.kvClient.Database(kvDatabase).Collection(dkCollection)
126126

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

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

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

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

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

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

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

13821382
expected := bsoncore.NewDocumentBuilder().
@@ -1727,8 +1727,8 @@ func TestClientSideEncryptionProse(t *testing.T) {
17271727
// Find.
17281728
res := coll.FindOne(context.Background(), bson.D{{"encryptedIndexed", findPayload}})
17291729
assert.Nil(mt, res.Err(), "Error in FindOne: %v", res.Err())
1730-
got, err := res.DecodeBytes()
1731-
assert.Nil(mt, err, "error in DecodeBytes: %v", err)
1730+
got, err := res.Raw()
1731+
assert.Nil(mt, err, "error in Raw: %v", err)
17321732
gotValue, err := got.LookupErr("encryptedIndexed")
17331733
assert.Nil(mt, err, "error in LookupErr: %v", err)
17341734
assert.Equal(mt, gotValue.StringValue(), valueToEncrypt, "expected %q, got %q", valueToEncrypt, gotValue.StringValue())
@@ -1808,8 +1808,8 @@ func TestClientSideEncryptionProse(t *testing.T) {
18081808
// Find.
18091809
res := coll.FindOne(context.Background(), bson.D{{"_id", 1}})
18101810
assert.Nil(mt, res.Err(), "Error in FindOne: %v", res.Err())
1811-
got, err := res.DecodeBytes()
1812-
assert.Nil(mt, err, "error in DecodeBytes: %v", err)
1811+
got, err := res.Raw()
1812+
assert.Nil(mt, err, "error in Raw: %v", err)
18131813
gotValue, err := got.LookupErr("encryptedUnindexed")
18141814
assert.Nil(mt, err, "error in LookupErr: %v", err)
18151815
assert.Equal(mt, gotValue.StringValue(), valueToEncrypt, "expected %q, got %q", valueToEncrypt, gotValue.StringValue())
@@ -1899,15 +1899,15 @@ func TestClientSideEncryptionProse(t *testing.T) {
18991899
var validateAddKeyAltName = func(mt *mtest.T, cse *cseProseTest, res *mongo.SingleResult, expected ...string) {
19001900
assert.Nil(mt, res.Err(), "error adding key alt name: %v", res.Err())
19011901

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

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

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

19131913
updated := bson.RawValue{Type: bsontype.EmbeddedDocument, Value: updatedData}

mongo/integration/client_side_encryption_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ func TestClientSideEncryptionCustomCrypt(t *testing.T) {
375375
res := coll.FindOne(context.Background(), bson.D{{"foo", "bar"}})
376376
assert.Nil(mt, res.Err(), "FindOne error: %v", err)
377377

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

593593
val := resBSON.Lookup("encryptedIndexed")
594594
assert.Equal(mt, val.Type, bsontype.Binary, "expected encryptedIndexed to be Binary, got %v", val.Type)

mongo/integration/client_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func TestClient(t *testing.T) {
187187

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

880880
if tc.wantRaw != nil {
881-
got, err := sr.DecodeBytes()
882-
require.NoError(mt, err, "DecodeBytes error")
881+
got, err := sr.Raw()
882+
require.NoError(mt, err, "Raw error")
883883

884884
assert.EqualBSON(mt, tc.wantRaw, got)
885885
}

mongo/integration/collection_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ func TestCollection(t *testing.T) {
11081108
})
11091109
mt.Run("found", func(mt *mtest.T) {
11101110
initCollection(mt, mt.Coll)
1111-
res, err := mt.Coll.FindOne(context.Background(), bson.D{{"x", 1}}).DecodeBytes()
1111+
res, err := mt.Coll.FindOne(context.Background(), bson.D{{"x", 1}}).Raw()
11121112
assert.Nil(mt, err, "FindOne error: %v", err)
11131113

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

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

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

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

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

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

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

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

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

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

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

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

14331433
if tc.errParam != "" {
14341434
expErr := mongo.ErrMapForOrderedArgument{tc.errParam}

mongo/integration/crud_helpers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,7 @@ func verifySingleResult(mt *mtest.T, actualResult *mongo.SingleResult, expectedR
16461646
}
16471647

16481648
expected := expectedResult.(bson.Raw)
1649-
actual, _ := actualResult.DecodeBytes()
1649+
actual, _ := actualResult.Raw()
16501650
if err := compareDocs(mt, expected, actual); err != nil {
16511651
mt.Fatalf("SingleResult document mismatch: %s", err)
16521652
}

mongo/integration/database_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestDatabase(t *testing.T) {
4141

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

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

110110
n, ok := res.Lookup("n").Int32OK()
111111
assert.True(mt, ok, "expected n in response")

mongo/integration/gridfs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ func TestGridFS(x *testing.T) {
297297
// The uploadDate field is calculated when the upload is complete. Manually fetch it from the
298298
// fs.files collection to use in assertions.
299299
filesColl := mt.DB.Collection("fs.files")
300-
uploadedFileDoc, err := filesColl.FindOne(context.Background(), bson.D{}).DecodeBytes()
300+
uploadedFileDoc, err := filesColl.FindOne(context.Background(), bson.D{}).Raw()
301301
assert.Nil(mt, err, "FindOne error: %v", err)
302302
uploadTime := uploadedFileDoc.Lookup("uploadDate").Time().UTC()
303303

mongo/integration/mtest/setup.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func Setup(setupOpts ...*SetupOptions) error {
196196

197197
testContext.authEnabled = os.Getenv("AUTH") == "auth"
198198
testContext.sslEnabled = os.Getenv("SSL") == "ssl"
199-
biRes, err := testContext.client.Database("admin").RunCommand(context.Background(), bson.D{{"buildInfo", 1}}).DecodeBytes()
199+
biRes, err := testContext.client.Database("admin").RunCommand(context.Background(), bson.D{{"buildInfo", 1}}).Raw()
200200
if err != nil {
201201
return fmt.Errorf("buildInfo error: %v", err)
202202
}
@@ -215,7 +215,7 @@ func Setup(setupOpts ...*SetupOptions) error {
215215
// Get server parameters if test is not running against ADL; ADL does not have "getParameter" command.
216216
if !testContext.dataLake {
217217
db := testContext.client.Database("admin")
218-
testContext.serverParameters, err = db.RunCommand(context.Background(), bson.D{{"getParameter", "*"}}).DecodeBytes()
218+
testContext.serverParameters, err = db.RunCommand(context.Background(), bson.D{{"getParameter", "*"}}).Raw()
219219
if err != nil {
220220
return fmt.Errorf("error getting serverParameters: %v", err)
221221
}

mongo/integration/retryable_writes_prose_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func TestRetryableWritesProse(t *testing.T) {
8686
})
8787
errorOpts := mtest.NewOptions().Topologies(mtest.ReplicaSet, mtest.Sharded)
8888
mt.RunOpts("wrap mmapv1 error", errorOpts, func(mt *mtest.T) {
89-
res, err := mt.DB.RunCommand(context.Background(), bson.D{{"serverStatus", 1}}).DecodeBytes()
89+
res, err := mt.DB.RunCommand(context.Background(), bson.D{{"serverStatus", 1}}).Raw()
9090
assert.Nil(mt, err, "serverStatus error: %v", err)
9191
storageEngine, ok := res.Lookup("storageEngine", "name").StringValueOK()
9292
if !ok || storageEngine != "mmapv1" {

mongo/integration/unified/client_encryption_operation_execution.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ func executeAddKeyAltName(ctx context.Context, operation *operation) (*operation
8383
}
8484
}
8585

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

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

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

294-
res, err := cee.RemoveKeyAltName(ctx, id, keyAltName).DecodeBytes()
295-
// Ignore ErrNoDocuments errors from DecodeBytes. In the event that the cursor returned in a find operation has no
296-
// associated documents, DecodeBytes will return ErrNoDocuments.
294+
res, err := cee.RemoveKeyAltName(ctx, id, keyAltName).Raw()
295+
// Ignore ErrNoDocuments errors from Raw. In the event that the cursor returned in a find operation has no
296+
// associated documents, Raw will return ErrNoDocuments.
297297
if err == mongo.ErrNoDocuments {
298298
err = nil
299299
}

mongo/integration/unified/collection_operation_execution.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -752,9 +752,9 @@ func executeFindOne(ctx context.Context, operation *operation) (*operationResult
752752
return nil, newMissingArgumentError("filter")
753753
}
754754

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

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

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

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

0 commit comments

Comments
 (0)