Skip to content

Commit

Permalink
GODRIVER-2649 Remove RW Concern Logic from RunCommand (#1450)
Browse files Browse the repository at this point in the history
  • Loading branch information
prestonvasquez authored Nov 2, 2023
1 parent 17f9d77 commit d52c9e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
15 changes: 9 additions & 6 deletions mongo/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,21 @@ func (db *Database) processRunCommand(ctx context.Context, cmd interface{},
op = operation.NewCommand(runCmdDoc)
}

// TODO(GODRIVER-2649): ReadConcern(db.readConcern) will not actually pass the database's
// read concern. Remove this note once readConcern is correctly passed to the operation
// level.
return op.Session(sess).CommandMonitor(db.client.monitor).
ServerSelector(readSelect).ClusterClock(db.client.clock).
Database(db.name).Deployment(db.client.deployment).ReadConcern(db.readConcern).
Database(db.name).Deployment(db.client.deployment).
Crypt(db.client.cryptFLE).ReadPreference(ro.ReadPreference).ServerAPI(db.client.serverAPI).
Timeout(db.client.timeout).Logger(db.client.logger), sess, nil
}

// RunCommand executes the given command against the database. This function does not obey the Database's read
// preference. To specify a read preference, the RunCmdOptions.ReadPreference option must be used.
// RunCommand executes the given command against the database.
//
// This function does not obey the Database's readPreference. To specify a read
// preference, the RunCmdOptions.ReadPreference option must be used.
//
// This function does not obey the Database's readConcern or writeConcern. A
// user must supply these values manually in the user-provided runCommand
// parameter.
//
// The runCommand parameter must be a document for the command to be executed. It cannot be nil.
// This must be an order-preserving type such as bson.D. Map types such as bson.M are not valid.
Expand Down
13 changes: 0 additions & 13 deletions x/mongo/driver/operation/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"go.mongodb.org/mongo-driver/event"
"go.mongodb.org/mongo-driver/internal/logger"
"go.mongodb.org/mongo-driver/mongo/description"
"go.mongodb.org/mongo-driver/mongo/readconcern"
"go.mongodb.org/mongo-driver/mongo/readpref"
"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
"go.mongodb.org/mongo-driver/x/mongo/driver"
Expand All @@ -24,7 +23,6 @@ import (
// Command is used to run a generic operation.
type Command struct {
command bsoncore.Document
readConcern *readconcern.ReadConcern
database string
deployment driver.Deployment
selector description.ServerSelector
Expand Down Expand Up @@ -79,7 +77,6 @@ func (c *Command) Execute(ctx context.Context) error {
return errors.New("the Command operation must have a Deployment set before Execute can be called")
}

// TODO(GODRIVER-2649): Actually pass readConcern to underlying driver.Operation.
return driver.Operation{
CommandFn: func(dst []byte, desc description.SelectedServer) ([]byte, error) {
return append(dst, c.command[4:len(c.command)-1]...), nil
Expand Down Expand Up @@ -163,16 +160,6 @@ func (c *Command) Deployment(deployment driver.Deployment) *Command {
return c
}

// ReadConcern specifies the read concern for this operation.
func (c *Command) ReadConcern(readConcern *readconcern.ReadConcern) *Command {
if c == nil {
c = new(Command)
}

c.readConcern = readConcern
return c
}

// ReadPreference set the read preference used with this operation.
func (c *Command) ReadPreference(readPreference *readpref.ReadPref) *Command {
if c == nil {
Expand Down

0 comments on commit d52c9e1

Please sign in to comment.