From f41a6ed9babc04776c63b0d1fa30dda0dfbe257c Mon Sep 17 00:00:00 2001 From: Isabella Siu Date: Tue, 11 May 2021 10:54:50 -0400 Subject: [PATCH] GODRIVER-1963 remove dropDatabase result (#660) --- x/mongo/driver/operation/drop_database.go | 56 ++++------------------- 1 file changed, 10 insertions(+), 46 deletions(-) diff --git a/x/mongo/driver/operation/drop_database.go b/x/mongo/driver/operation/drop_database.go index 074c931c3e..47bf4f8715 100644 --- a/x/mongo/driver/operation/drop_database.go +++ b/x/mongo/driver/operation/drop_database.go @@ -11,7 +11,6 @@ package operation import ( "context" "errors" - "fmt" "go.mongodb.org/mongo-driver/event" "go.mongodb.org/mongo-driver/mongo/description" @@ -31,48 +30,14 @@ type DropDatabase struct { deployment driver.Deployment selector description.ServerSelector writeConcern *writeconcern.WriteConcern - result DropDatabaseResult serverAPI *driver.ServerAPIOptions } -type DropDatabaseResult struct { - // The dropped database. - Dropped string -} - -func buildDropDatabaseResult(response bsoncore.Document, srvr driver.Server) (DropDatabaseResult, error) { - elements, err := response.Elements() - if err != nil { - return DropDatabaseResult{}, err - } - ddr := DropDatabaseResult{} - for _, element := range elements { - switch element.Key() { - case "dropped": - var ok bool - ddr.Dropped, ok = element.Value().StringValueOK() - if !ok { - err = fmt.Errorf("response field 'dropped' is type string, but received BSON type %s", element.Value().Type) - } - } - } - return ddr, nil -} - // NewDropDatabase constructs and returns a new DropDatabase. func NewDropDatabase() *DropDatabase { return &DropDatabase{} } -// Result returns the result of executing this operation. -func (dd *DropDatabase) Result() DropDatabaseResult { return dd.result } - -func (dd *DropDatabase) processResponse(info driver.ResponseInfo) error { - var err error - dd.result, err = buildDropDatabaseResult(info.ServerResponse, info.Server) - return err -} - // Execute runs this operations and returns an error if the operaiton did not execute successfully. func (dd *DropDatabase) Execute(ctx context.Context) error { if dd.deployment == nil { @@ -80,17 +45,16 @@ func (dd *DropDatabase) Execute(ctx context.Context) error { } return driver.Operation{ - CommandFn: dd.command, - ProcessResponseFn: dd.processResponse, - Client: dd.session, - Clock: dd.clock, - CommandMonitor: dd.monitor, - Crypt: dd.crypt, - Database: dd.database, - Deployment: dd.deployment, - Selector: dd.selector, - WriteConcern: dd.writeConcern, - ServerAPI: dd.serverAPI, + CommandFn: dd.command, + Client: dd.session, + Clock: dd.clock, + CommandMonitor: dd.monitor, + Crypt: dd.crypt, + Database: dd.database, + Deployment: dd.deployment, + Selector: dd.selector, + WriteConcern: dd.writeConcern, + ServerAPI: dd.serverAPI, }.Execute(ctx, nil) }