Skip to content

Commit

Permalink
GODRIVER-961 Change IndexView.DropAll to not return bson.Raw
Browse files Browse the repository at this point in the history
  • Loading branch information
prestonvasquez committed Oct 9, 2023
1 parent 98f853f commit e1b1672
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
18 changes: 10 additions & 8 deletions mongo/index_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,16 +425,18 @@ func (iv IndexView) DropOne(ctx context.Context, name string, opts ...*options.D
return iv.drop(ctx, name, opts...)
}

// DropAll executes a dropIndexes operation to drop all indexes on the collection. If the operation succeeds, this
// returns a BSON document in the form {nIndexesWas: <int32>}. The "nIndexesWas" field in the response contains the
// number of indexes that existed prior to the drop.
// DropAll executes a dropIndexes operation to drop all indexes on the
// collection.
//
// The opts parameter can be used to specify options for this operation (see the options.DropIndexesOptions
// documentation).
// The opts parameter can be used to specify options for this operation (see the
// options.DropIndexesOptions documentation).
//
// For more information about the command, see https://www.mongodb.com/docs/manual/reference/command/dropIndexes/.
func (iv IndexView) DropAll(ctx context.Context, opts ...*options.DropIndexesOptions) (bson.Raw, error) {
return iv.drop(ctx, "*", opts...)
// For more information about the command, see
// https://www.mongodb.com/docs/manual/reference/command/dropIndexes/.
func (iv IndexView) DropAll(ctx context.Context, opts ...*options.DropIndexesOptions) error {
_, err := iv.drop(ctx, "*", opts...)

return err
}

func getOrGenerateIndexName(keySpecDocument bsoncore.Document, model IndexModel) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion mongo/integration/index_view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ func TestIndexView(t *testing.T) {
})
assert.Nil(mt, err, "CreateMany error: %v", err)
assert.Equal(mt, 2, len(names), "expected 2 index names, got %v", len(names))
_, err = iv.DropAll(context.Background())
err = iv.DropAll(context.Background())
assert.Nil(mt, err, "DropAll error: %v", err)

cursor, err := iv.List(context.Background())
Expand Down
4 changes: 2 additions & 2 deletions mongo/integration/unified/collection_operation_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,8 @@ func executeDropIndexes(ctx context.Context, operation *operation) (*operationRe
}
}

res, err := coll.Indexes().DropAll(ctx, dropIndexOpts)
return newDocumentResult(res, err), nil
err = coll.Indexes().DropAll(ctx, dropIndexOpts)
return newDocumentResult(nil, err), nil
}

func executeDropSearchIndex(ctx context.Context, operation *operation) (*operationResult, error) {
Expand Down

0 comments on commit e1b1672

Please sign in to comment.