diff --git a/.gitmodules b/.gitmodules index e3b5c7b3ee..a403967b4e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "specifications"] path = testdata/specifications - url = https://github.com/mongodb/specifications + url = https://github.com/qingyang-hu/specifications.git + branch = drivers3064 diff --git a/internal/integration/unified/client_operation_execution.go b/internal/integration/unified/client_operation_execution.go index 75948ff8a0..432852dd71 100644 --- a/internal/integration/unified/client_operation_execution.go +++ b/internal/integration/unified/client_operation_execution.go @@ -19,6 +19,7 @@ import ( "go.mongodb.org/mongo-driver/v2/mongo" "go.mongodb.org/mongo-driver/v2/mongo/options" "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/xoptions" ) // This file contains helpers to execute client operations. @@ -235,6 +236,11 @@ func executeClientBulkWrite(ctx context.Context, operation *operation) (*operati return nil, err } opts.SetWriteConcern(c) + case "rawData": + err = xoptions.SetInternalClientBulkWriteOptions(opts, key, val.Boolean()) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("unrecognized bulkWrite option %q", key) } diff --git a/internal/integration/unified/collection_operation_execution.go b/internal/integration/unified/collection_operation_execution.go index c3e7040256..26537bce7e 100644 --- a/internal/integration/unified/collection_operation_execution.go +++ b/internal/integration/unified/collection_operation_execution.go @@ -19,6 +19,7 @@ import ( "go.mongodb.org/mongo-driver/v2/mongo" "go.mongodb.org/mongo-driver/v2/mongo/options" "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/xoptions" ) // This file contains helpers to execute collection operations. @@ -75,6 +76,11 @@ func executeAggregate(ctx context.Context, operation *operation) (*operationResu pipeline = bsonutil.RawToInterfaces(bsonutil.RawArrayToDocuments(val.Array())...) case "let": opts.SetLet(val.Document()) + case "rawData": + err = xoptions.SetInternalAggregateOptions(opts, key, val.Boolean()) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("unrecognized aggregate option %q", key) } @@ -125,6 +131,11 @@ func executeBulkWrite(ctx context.Context, operation *operation) (*operationResu } case "let": opts.SetLet(val.Document()) + case "rawData": + err = xoptions.SetInternalBulkWriteOptions(opts, key, val.Boolean()) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("unrecognized bulkWrite option %q", key) } @@ -202,6 +213,11 @@ func executeCountDocuments(ctx context.Context, operation *operation) (*operatio return nil, fmt.Errorf("the maxTimeMS collection option is not supported") case "skip": opts.SetSkip(int64(val.Int32())) + case "rawData": + err = xoptions.SetInternalCountOptions(opts, key, val.Boolean()) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("unrecognized countDocuments option %q", key) } @@ -225,6 +241,7 @@ func executeCreateIndex(ctx context.Context, operation *operation) (*operationRe var keys bson.Raw indexOpts := options.Index() + opts := options.CreateIndexes() elems, err := operation.Arguments.Elements() if err != nil { @@ -279,6 +296,11 @@ func executeCreateIndex(ctx context.Context, operation *operation) (*operationRe indexOpts.SetWeights(val.Document()) case "wildcardProjection": indexOpts.SetWildcardProjection(val.Document()) + case "rawData": + err = xoptions.SetInternalCreateIndexesOptions(opts, key, val.Boolean()) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("unrecognized createIndex option %q", key) } @@ -291,7 +313,8 @@ func executeCreateIndex(ctx context.Context, operation *operation) (*operationRe Keys: keys, Options: indexOpts, } - name, err := coll.Indexes().CreateOne(ctx, model) + + name, err := coll.Indexes().CreateOne(ctx, model, opts) return newValueResult(bson.TypeString, bsoncore.AppendString(nil, name), err), nil } @@ -433,6 +456,11 @@ func executeDeleteOne(ctx context.Context, operation *operation) (*operationResu opts.SetHint(hint) case "let": opts.SetLet(val.Document()) + case "rawData": + err = xoptions.SetInternalDeleteOneOptions(opts, key, val.Boolean()) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("unrecognized deleteOne option %q", key) } @@ -487,6 +515,11 @@ func executeDeleteMany(ctx context.Context, operation *operation) (*operationRes opts.SetHint(hint) case "let": opts.SetLet(val.Document()) + case "rawData": + err = xoptions.SetInternalDeleteManyOptions(opts, key, val.Boolean()) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("unrecognized deleteMany option %q", key) } @@ -545,6 +578,11 @@ func executeDistinct(ctx context.Context, operation *operation) (*operationResul // ensured an analogue exists, extend "skippedTestDescriptions" to avoid // this error. return nil, fmt.Errorf("the maxTimeMS collection option is not supported") + case "rawData": + err = xoptions.SetInternalDistinctOptions(opts, key, val.Boolean()) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("unrecognized distinct option %q", key) } @@ -593,6 +631,11 @@ func executeDropIndex(ctx context.Context, operation *operation) (*operationResu // ensured an analogue exists, extend "skippedTestDescriptions" to avoid // this error. return nil, fmt.Errorf("the maxTimeMS collection option is not supported") + case "rawData": + err = xoptions.SetInternalDropIndexesOptions(dropIndexOpts, key, val.Boolean()) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("unrecognized dropIndex option %q", key) } @@ -690,6 +733,11 @@ func executeEstimatedDocumentCount(ctx context.Context, operation *operation) (* // ensured an analogue exists, extend "skippedTestDescriptions" to avoid // this error. return nil, fmt.Errorf("the maxTimeMS collection option is not supported") + case "rawData": + err = xoptions.SetInternalEstimatedDocumentCountOptions(opts, key, val.Boolean()) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("unrecognized estimatedDocumentCount option %q", key) } @@ -842,6 +890,11 @@ func executeFindOneAndDelete(ctx context.Context, operation *operation) (*operat opts.SetSort(val.Document()) case "let": opts.SetLet(val.Document()) + case "rawData": + err = xoptions.SetInternalFindOneAndDeleteOptions(opts, key, val.Boolean()) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("unrecognized findOneAndDelete option %q", key) } @@ -924,6 +977,11 @@ func executeFindOneAndReplace(ctx context.Context, operation *operation) (*opera opts.SetSort(val.Document()) case "upsert": opts.SetUpsert(val.Boolean()) + case "rawData": + err = xoptions.SetInternalFindOneAndReplaceOptions(opts, key, val.Boolean()) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("unrecognized findOneAndReplace option %q", key) } @@ -1016,6 +1074,11 @@ func executeFindOneAndUpdate(ctx context.Context, operation *operation) (*operat } case "upsert": opts.SetUpsert(val.Boolean()) + case "rawData": + err = xoptions.SetInternalFindOneAndUpdateOptions(opts, key, val.Boolean()) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("unrecognized findOneAndUpdate option %q", key) } @@ -1062,6 +1125,11 @@ func executeInsertMany(ctx context.Context, operation *operation) (*operationRes documents = bsonutil.RawToInterfaces(bsonutil.RawArrayToDocuments(val.Array())...) case "ordered": opts.SetOrdered(val.Boolean()) + case "rawData": + err = xoptions.SetInternalInsertManyOptions(opts, key, val.Boolean()) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("unrecognized insertMany option %q", key) } @@ -1112,6 +1180,11 @@ func executeInsertOne(ctx context.Context, operation *operation) (*operationResu opts.SetBypassDocumentValidation(val.Boolean()) case "comment": opts.SetComment(val) + case "rawData": + err = xoptions.SetInternalInsertOneOptions(opts, key, val.Boolean()) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("unrecognized insertOne option %q", key) } @@ -1156,6 +1229,11 @@ func executeListIndexes(ctx context.Context, operation *operation) (*operationRe switch key { case "batchSize": opts.SetBatchSize(val.Int32()) + case "rawData": + err = xoptions.SetInternalListIndexesOptions(opts, key, val.Boolean()) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("unrecognized listIndexes option: %q", key) } @@ -1302,6 +1380,11 @@ func executeReplaceOne(ctx context.Context, operation *operation) (*operationRes opts.SetUpsert(val.Boolean()) case "let": opts.SetLet(val.Document()) + case "rawData": + err = xoptions.SetInternalReplaceOptions(opts, key, val.Boolean()) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("unrecognized replaceOne option %q", key) } @@ -1500,6 +1583,11 @@ func createFindCursor(ctx context.Context, operation *operation) (*cursorResult, case "maxAwaitTimeMS": maxAwaitTimeMS := time.Duration(val.Int32()) * time.Millisecond opts.SetMaxAwaitTime(maxAwaitTimeMS) + case "rawData": + err = xoptions.SetInternalFindOptions(opts, key, val.Boolean()) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("unrecognized find option %q", key) } diff --git a/internal/integration/unified/crud_helpers.go b/internal/integration/unified/crud_helpers.go index 34de29d683..f24e1f9be7 100644 --- a/internal/integration/unified/crud_helpers.go +++ b/internal/integration/unified/crud_helpers.go @@ -12,6 +12,7 @@ import ( "go.mongodb.org/mongo-driver/v2/bson" "go.mongodb.org/mongo-driver/v2/internal/bsonutil" "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/xoptions" ) // newMissingArgumentError creates an error to convey that an argument that is required to run an operation is missing @@ -67,6 +68,11 @@ func createUpdateManyArguments(args bson.Raw) (*updateArguments, *options.Update } case "upsert": opts.SetUpsert(val.Boolean()) + case "rawData": + err := xoptions.SetInternalUpdateManyOptions(opts, key, val.Boolean()) + if err != nil { + return nil, nil, err + } default: return nil, nil, fmt.Errorf("unrecognized update option %q", key) } @@ -125,6 +131,11 @@ func createUpdateOneArguments(args bson.Raw) (*updateArguments, *options.UpdateO opts.SetUpsert(val.Boolean()) case "sort": opts.SetSort(val.Document()) + case "rawData": + err := xoptions.SetInternalUpdateOneOptions(opts, key, val.Boolean()) + if err != nil { + return nil, nil, err + } default: return nil, nil, fmt.Errorf("unrecognized update option %q", key) } @@ -162,6 +173,11 @@ func createListCollectionsArguments(args bson.Raw) (*listCollectionsArguments, e lca.filter = val.Document() case "nameOnly": lca.opts.SetNameOnly(val.Boolean()) + case "rawData": + err := xoptions.SetInternalListCollectionsOptions(lca.opts, key, val.Boolean()) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("unrecognized listCollections option %q", key) } diff --git a/mongo/bulk_write.go b/mongo/bulk_write.go index 415a90ae55..7a3181c6c4 100644 --- a/mongo/bulk_write.go +++ b/mongo/bulk_write.go @@ -39,6 +39,7 @@ type bulkWrite struct { writeConcern *writeconcern.WriteConcern result BulkWriteResult let interface{} + rawData *bool } func (bw *bulkWrite) execute(ctx context.Context) error { @@ -209,6 +210,10 @@ func (bw *bulkWrite) runInsert(ctx context.Context, batch bulkWriteBatch) (opera } op = op.Retry(retry) + if bw.rawData != nil { + op.RawData(*bw.rawData) + } + err := op.Execute(ctx) return op.Result(), err @@ -282,6 +287,10 @@ func (bw *bulkWrite) runDelete(ctx context.Context, batch bulkWriteBatch) (opera } op = op.Retry(retry) + if bw.rawData != nil { + op.RawData(*bw.rawData) + } + err := op.Execute(ctx) return op.Result(), err @@ -415,6 +424,10 @@ func (bw *bulkWrite) runUpdate(ctx context.Context, batch bulkWriteBatch) (opera } op = op.Retry(retry) + if bw.rawData != nil { + op.RawData(*bw.rawData) + } + err := op.Execute(ctx) return op.Result(), err diff --git a/mongo/client.go b/mongo/client.go index 885246a211..9140e178af 100644 --- a/mongo/client.go +++ b/mongo/client.go @@ -18,6 +18,7 @@ import ( "go.mongodb.org/mongo-driver/v2/internal/httputil" "go.mongodb.org/mongo-driver/v2/internal/logger" "go.mongodb.org/mongo-driver/v2/internal/mongoutil" + "go.mongodb.org/mongo-driver/v2/internal/optionsutil" "go.mongodb.org/mongo-driver/v2/internal/ptrutil" "go.mongodb.org/mongo-driver/v2/internal/serverselector" "go.mongodb.org/mongo-driver/v2/internal/uuid" @@ -957,6 +958,11 @@ func (c *Client) BulkWrite(ctx context.Context, writes []ClientBulkWrite, selector: selector, writeConcern: wc, } + if rawDataOpt := optionsutil.Value(bwo.Internal, "rawData"); rawDataOpt != nil { + if rawData, ok := rawDataOpt.(bool); ok { + op.rawData = &rawData + } + } if bwo.VerboseResults == nil || !(*bwo.VerboseResults) { op.errorsOnly = true } else if !acknowledged { diff --git a/mongo/client_bulk_write.go b/mongo/client_bulk_write.go index ca6ecf5240..7a0d557881 100644 --- a/mongo/client_bulk_write.go +++ b/mongo/client_bulk_write.go @@ -44,6 +44,7 @@ type clientBulkWrite struct { client *Client selector description.ServerSelector writeConcern *writeconcern.WriteConcern + rawData *bool result ClientBulkWriteResult } @@ -143,6 +144,10 @@ func (bw *clientBulkWrite) newCommand() func([]byte, description.SelectedServer) } dst = bsoncore.AppendDocumentElement(dst, "let", let) } + // Set rawData for 8.2+ servers. + if bw.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *bw.rawData) + } return dst, nil } } diff --git a/mongo/collection.go b/mongo/collection.go index 6acadc285e..80c15c48d0 100644 --- a/mongo/collection.go +++ b/mongo/collection.go @@ -17,6 +17,7 @@ import ( "go.mongodb.org/mongo-driver/v2/bson" "go.mongodb.org/mongo-driver/v2/internal/csfle" "go.mongodb.org/mongo-driver/v2/internal/mongoutil" + "go.mongodb.org/mongo-driver/v2/internal/optionsutil" "go.mongodb.org/mongo-driver/v2/internal/serverselector" "go.mongodb.org/mongo-driver/v2/mongo/options" "go.mongodb.org/mongo-driver/v2/mongo/readconcern" @@ -245,6 +246,11 @@ func (coll *Collection) BulkWrite(ctx context.Context, models []WriteModel, writeConcern: wc, let: args.Let, } + if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil { + if rawData, ok := rawDataOpt.(bool); ok { + op.rawData = &rawData + } + } err = op.execute(ctx) @@ -324,6 +330,11 @@ func (coll *Collection) insert( if args.Ordered != nil { op = op.Ordered(*args.Ordered) } + if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil { + if rawData, ok := rawDataOpt.(bool); ok { + op = op.RawData(rawData) + } + } retry := driver.RetryNone if coll.client.retryWrites { retry = driver.RetryOncePerCommand @@ -375,6 +386,13 @@ func (coll *Collection) InsertOne(ctx context.Context, document interface{}, if args.Comment != nil { imOpts.SetComment(args.Comment) } + if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil { + imOpts.Opts = append(imOpts.Opts, func(opts *options.InsertManyOptions) error { + optionsutil.WithValue(opts.Internal, "rawData", rawDataOpt) + + return nil + }) + } res, err := coll.insert(ctx, []interface{}{document}, imOpts) rr, err := processWriteError(err) @@ -534,6 +552,11 @@ func (coll *Collection) delete( } op = op.Let(let) } + if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil { + if rawData, ok := rawDataOpt.(bool); ok { + op = op.RawData(rawData) + } + } // deleteMany cannot be retried retryMode := driver.RetryNone @@ -575,6 +598,7 @@ func (coll *Collection) DeleteOne( Comment: args.Comment, Hint: args.Hint, Let: args.Let, + Internal: args.Internal, } return coll.delete(ctx, filter, true, rrOne, deleteOptions) @@ -681,6 +705,11 @@ func (coll *Collection) updateOrReplace( } op = op.Comment(comment) } + if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil { + if rawData, ok := rawDataOpt.(bool); ok { + op = op.RawData(rawData) + } + } retry := driver.RetryNone // retryable writes are only enabled updateOne/replaceOne operations if !multi && coll.client.retryWrites { @@ -775,6 +804,7 @@ func (coll *Collection) UpdateOne( Hint: args.Hint, Upsert: args.Upsert, Let: args.Let, + Internal: args.Internal, } return coll.updateOrReplace(ctx, f, update, false, rrOne, true, args.Sort, updateOptions) @@ -865,6 +895,7 @@ func (coll *Collection) ReplaceOne( Hint: args.Hint, Let: args.Let, Comment: args.Comment, + Internal: args.Internal, } return coll.updateOrReplace(ctx, f, r, false, rrOne, false, args.Sort, updateOptions) @@ -1036,6 +1067,11 @@ func aggregate(a aggregateParams, opts ...options.Lister[options.AggregateOption } op.CustomOptions(customOptions) } + if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil { + if rawData, ok := rawDataOpt.(bool); ok { + op = op.RawData(rawData) + } + } retry := driver.RetryNone if a.retryRead && !hasOutputStage { @@ -1124,6 +1160,11 @@ func (coll *Collection) CountDocuments(ctx context.Context, filter interface{}, } op.Hint(hintVal) } + if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil { + if rawData, ok := rawDataOpt.(bool); ok { + op = op.RawData(rawData) + } + } retry := driver.RetryNone if coll.client.retryReads { retry = driver.RetryOncePerCommand @@ -1205,6 +1246,11 @@ func (coll *Collection) EstimatedDocumentCount( } op = op.Comment(comment) } + if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil { + if rawData, ok := rawDataOpt.(bool); ok { + op = op.RawData(rawData) + } + } retry := driver.RetryNone if coll.client.retryReads { @@ -1294,6 +1340,11 @@ func (coll *Collection) Distinct( } op.Hint(hint) } + if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil { + if rawData, ok := rawDataOpt.(bool); ok { + op = op.RawData(rawData) + } + } retry := driver.RetryNone if coll.client.retryReads { retry = driver.RetryOncePerCommand @@ -1497,6 +1548,11 @@ func (coll *Collection) find( } op.Sort(sort) } + if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil { + if rawData, ok := rawDataOpt.(bool); ok { + op = op.RawData(rawData) + } + } retry := driver.RetryNone if coll.client.retryReads { retry = driver.RetryOncePerCommand @@ -1530,6 +1586,7 @@ func newFindArgsFromFindOneArgs(args *options.FindOneOptions) *options.FindOptio v.ShowRecordID = args.ShowRecordID v.Skip = args.Skip v.Sort = args.Sort + v.Internal = args.Internal } return v } @@ -1692,6 +1749,11 @@ func (coll *Collection) FindOneAndDelete( } op = op.Let(let) } + if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil { + if rawData, ok := rawDataOpt.(bool); ok { + op = op.RawData(rawData) + } + } return coll.findAndModify(ctx, op) } @@ -1789,6 +1851,11 @@ func (coll *Collection) FindOneAndReplace( } op = op.Let(let) } + if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil { + if rawData, ok := rawDataOpt.(bool); ok { + op = op.RawData(rawData) + } + } return coll.findAndModify(ctx, op) } @@ -1898,6 +1965,11 @@ func (coll *Collection) FindOneAndUpdate( } op = op.Let(let) } + if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil { + if rawData, ok := rawDataOpt.(bool); ok { + op = op.RawData(rawData) + } + } return coll.findAndModify(ctx, op) } diff --git a/mongo/database.go b/mongo/database.go index a3269ddf16..8476aeb201 100644 --- a/mongo/database.go +++ b/mongo/database.go @@ -16,6 +16,7 @@ import ( "go.mongodb.org/mongo-driver/v2/internal/csfle" "go.mongodb.org/mongo-driver/v2/internal/csot" "go.mongodb.org/mongo-driver/v2/internal/mongoutil" + "go.mongodb.org/mongo-driver/v2/internal/optionsutil" "go.mongodb.org/mongo-driver/v2/internal/serverselector" "go.mongodb.org/mongo-driver/v2/mongo/options" "go.mongodb.org/mongo-driver/v2/mongo/readconcern" @@ -487,6 +488,11 @@ func (db *Database) ListCollections( if args.AuthorizedCollections != nil { op = op.AuthorizedCollections(*args.AuthorizedCollections) } + if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil { + if rawData, ok := rawDataOpt.(bool); ok { + op = op.RawData(rawData) + } + } retry := driver.RetryNone if db.client.retryReads { diff --git a/mongo/index_view.go b/mongo/index_view.go index a0734ebf16..7198c4cc43 100644 --- a/mongo/index_view.go +++ b/mongo/index_view.go @@ -14,6 +14,7 @@ import ( "strconv" "go.mongodb.org/mongo-driver/v2/internal/mongoutil" + "go.mongodb.org/mongo-driver/v2/internal/optionsutil" "go.mongodb.org/mongo-driver/v2/internal/serverselector" "go.mongodb.org/mongo-driver/v2/mongo/options" "go.mongodb.org/mongo-driver/v2/mongo/readpref" @@ -101,6 +102,11 @@ func (iv IndexView) List(ctx context.Context, opts ...options.Lister[options.Lis op = op.BatchSize(*args.BatchSize) cursorOpts.BatchSize = *args.BatchSize } + if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil { + if rawData, ok := rawDataOpt.(bool); ok { + op = op.RawData(rawData) + } + } retry := driver.RetryNone if iv.coll.client.retryReads { @@ -279,6 +285,11 @@ func (iv IndexView) CreateMany( op.CommitQuorum(commitQuorum) } + if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil { + if rawData, ok := rawDataOpt.(bool); ok { + op = op.RawData(rawData) + } + } _, err = processWriteError(op.Execute(ctx)) if err != nil { @@ -376,7 +387,12 @@ func (iv IndexView) createOptionsDoc(opts options.Lister[options.IndexOptions]) return optsDoc, nil } -func (iv IndexView) drop(ctx context.Context, index any, _ ...options.Lister[options.DropIndexesOptions]) error { +func (iv IndexView) drop(ctx context.Context, index any, opts ...options.Lister[options.DropIndexesOptions]) error { + args, err := mongoutil.NewOptions[options.DropIndexesOptions](opts...) + if err != nil { + return fmt.Errorf("failed to construct options from builder: %w", err) + } + if ctx == nil { ctx = context.Background() } @@ -387,7 +403,7 @@ func (iv IndexView) drop(ctx context.Context, index any, _ ...options.Lister[opt defer sess.EndSession() } - err := iv.coll.client.validSession(sess) + err = iv.coll.client.validSession(sess) if err != nil { return err } @@ -408,6 +424,12 @@ func (iv IndexView) drop(ctx context.Context, index any, _ ...options.Lister[opt Deployment(iv.coll.client.deployment).ServerAPI(iv.coll.client.serverAPI). Timeout(iv.coll.client.timeout).Crypt(iv.coll.client.cryptFLE).Authenticator(iv.coll.client.authenticator) + if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil { + if rawData, ok := rawDataOpt.(bool); ok { + op = op.RawData(rawData) + } + } + err = op.Execute(ctx) if err != nil { return wrapErrors(err) diff --git a/mongo/options/aggregateoptions.go b/mongo/options/aggregateoptions.go index cf419677dc..070e126583 100644 --- a/mongo/options/aggregateoptions.go +++ b/mongo/options/aggregateoptions.go @@ -10,6 +10,7 @@ import ( "time" "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/optionsutil" ) // AggregateOptions represents arguments that can be used to configure an @@ -26,6 +27,10 @@ type AggregateOptions struct { Hint interface{} Let interface{} Custom bson.M + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // AggregateOptionsBuilder contains options to configure aggregate operations. diff --git a/mongo/options/bulkwriteoptions.go b/mongo/options/bulkwriteoptions.go index 186e83a0c5..20d0395efe 100644 --- a/mongo/options/bulkwriteoptions.go +++ b/mongo/options/bulkwriteoptions.go @@ -6,6 +6,8 @@ package options +import "go.mongodb.org/mongo-driver/v2/internal/optionsutil" + // DefaultOrdered is the default value for the Ordered option in BulkWriteOptions. var DefaultOrdered = true @@ -18,6 +20,10 @@ type BulkWriteOptions struct { Comment interface{} Ordered *bool Let interface{} + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // BulkWriteOptionsBuilder contains options to configure bulk write operations. diff --git a/mongo/options/clientbulkwriteoptions.go b/mongo/options/clientbulkwriteoptions.go index a55ac27f05..fd6933822b 100644 --- a/mongo/options/clientbulkwriteoptions.go +++ b/mongo/options/clientbulkwriteoptions.go @@ -7,6 +7,7 @@ package options import ( + "go.mongodb.org/mongo-driver/v2/internal/optionsutil" "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" ) @@ -20,6 +21,10 @@ type ClientBulkWriteOptions struct { Let interface{} WriteConcern *writeconcern.WriteConcern VerboseResults *bool + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // ClientBulkWriteOptionsBuilder contains options to configure client-level bulk diff --git a/mongo/options/countoptions.go b/mongo/options/countoptions.go index 27df828b00..3e689d9a54 100644 --- a/mongo/options/countoptions.go +++ b/mongo/options/countoptions.go @@ -6,6 +6,8 @@ package options +import "go.mongodb.org/mongo-driver/v2/internal/optionsutil" + // CountOptions represents arguments that can be used to configure a // CountDocuments operation. // @@ -16,6 +18,10 @@ type CountOptions struct { Hint interface{} Limit *int64 Skip *int64 + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // CountOptionsBuilder contains options to configure count operations. Each diff --git a/mongo/options/deleteoptions.go b/mongo/options/deleteoptions.go index 1d045d9960..27a77b4581 100644 --- a/mongo/options/deleteoptions.go +++ b/mongo/options/deleteoptions.go @@ -6,6 +6,8 @@ package options +import "go.mongodb.org/mongo-driver/v2/internal/optionsutil" + // DeleteOneOptions represents arguments that can be used to configure DeleteOne // operations. // @@ -15,6 +17,10 @@ type DeleteOneOptions struct { Comment interface{} Hint interface{} Let interface{} + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // DeleteOneOptionsBuilder contains options to configure DeleteOne operations. Each @@ -102,6 +108,10 @@ type DeleteManyOptions struct { Comment interface{} Hint interface{} Let interface{} + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // DeleteManyOptionsBuilder contains options to configure DeleteMany operations. diff --git a/mongo/options/distinctoptions.go b/mongo/options/distinctoptions.go index 3449ecee36..346432c07a 100644 --- a/mongo/options/distinctoptions.go +++ b/mongo/options/distinctoptions.go @@ -6,6 +6,8 @@ package options +import "go.mongodb.org/mongo-driver/v2/internal/optionsutil" + // DistinctOptions represents arguments that can be used to configure a Distinct // operation. // @@ -14,6 +16,10 @@ type DistinctOptions struct { Collation *Collation Comment interface{} Hint interface{} + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // DistinctOptionsBuilder contains options to configure distinct operations. Each diff --git a/mongo/options/estimatedcountoptions.go b/mongo/options/estimatedcountoptions.go index 2bee45a8f6..ccddd98c59 100644 --- a/mongo/options/estimatedcountoptions.go +++ b/mongo/options/estimatedcountoptions.go @@ -6,12 +6,18 @@ package options +import "go.mongodb.org/mongo-driver/v2/internal/optionsutil" + // EstimatedDocumentCountOptions represents arguments that can be used to configure // an EstimatedDocumentCount operation. // // See corresponding setter methods for documentation. type EstimatedDocumentCountOptions struct { Comment interface{} + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // EstimatedDocumentCountOptionsBuilder contains options to estimate document diff --git a/mongo/options/findoptions.go b/mongo/options/findoptions.go index ea627900ea..dd66eabc7a 100644 --- a/mongo/options/findoptions.go +++ b/mongo/options/findoptions.go @@ -8,6 +8,8 @@ package options import ( "time" + + "go.mongodb.org/mongo-driver/v2/internal/optionsutil" ) // FindOptions represents arguments that can be used to configure a Find @@ -35,6 +37,10 @@ type FindOptions struct { Let interface{} Limit *int64 NoCursorTimeout *bool + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // FindOptionsBuilder represents functional options that configure an Findopts. @@ -285,6 +291,10 @@ type FindOneOptions struct { ShowRecordID *bool Skip *int64 Sort interface{} + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // FindOneOptionsBuilder represents functional options that configure an @@ -450,6 +460,10 @@ type FindOneAndReplaceOptions struct { Upsert *bool Hint interface{} Let interface{} + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // FindOneAndReplaceOptionsBuilder contains options to perform a findAndModify @@ -611,6 +625,10 @@ type FindOneAndUpdateOptions struct { Upsert *bool Hint interface{} Let interface{} + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // FindOneAndUpdateOptionsBuilder contains options to configure a @@ -782,6 +800,10 @@ type FindOneAndDeleteOptions struct { Sort interface{} Hint interface{} Let interface{} + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // FindOneAndDeleteOptionsBuilder contains options to configure delete diff --git a/mongo/options/indexoptions.go b/mongo/options/indexoptions.go index b7b61c2edf..792bd827a7 100644 --- a/mongo/options/indexoptions.go +++ b/mongo/options/indexoptions.go @@ -6,12 +6,18 @@ package options +import "go.mongodb.org/mongo-driver/v2/internal/optionsutil" + // CreateIndexesOptions represents arguments that can be used to configure // IndexView.CreateOne and IndexView.CreateMany operations. // // See corresponding setter methods for documentation. type CreateIndexesOptions struct { CommitQuorum interface{} + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // CreateIndexesOptionsBuilder contains options to create indexes. Each option @@ -121,7 +127,11 @@ func (c *CreateIndexesOptionsBuilder) SetCommitQuorumVotingMembers() *CreateInde // DropIndexesOptions represents arguments that can be used to configure // IndexView.DropOne and IndexView.DropAll operations. -type DropIndexesOptions struct{} +type DropIndexesOptions struct { + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options +} // DropIndexesOptionsBuilder contains options to configure dropping indexes. // Each option can be set through setter functions. See documentation for each @@ -146,6 +156,10 @@ func (d *DropIndexesOptionsBuilder) List() []func(*DropIndexesOptions) error { // See corresponding setter methods for documentation. type ListIndexesOptions struct { BatchSize *int32 + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // ListIndexesOptionsBuilder contains options to configure count operations. Each diff --git a/mongo/options/insertoptions.go b/mongo/options/insertoptions.go index 61745600a9..36f18a987d 100644 --- a/mongo/options/insertoptions.go +++ b/mongo/options/insertoptions.go @@ -6,6 +6,8 @@ package options +import "go.mongodb.org/mongo-driver/v2/internal/optionsutil" + // InsertOneOptions represents arguments that can be used to configure an InsertOne // operation. // @@ -13,6 +15,10 @@ package options type InsertOneOptions struct { BypassDocumentValidation *bool Comment interface{} + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // InsertOneOptionsBuilder represents functional options that configure an @@ -61,6 +67,10 @@ type InsertManyOptions struct { BypassDocumentValidation *bool Comment interface{} Ordered *bool + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // InsertManyOptionsBuilder contains options to configure insert operations. diff --git a/mongo/options/listcollectionsoptions.go b/mongo/options/listcollectionsoptions.go index 2106b2f906..14f96cc627 100644 --- a/mongo/options/listcollectionsoptions.go +++ b/mongo/options/listcollectionsoptions.go @@ -6,6 +6,8 @@ package options +import "go.mongodb.org/mongo-driver/v2/internal/optionsutil" + // ListCollectionsOptions represents arguments that can be used to configure a // ListCollections operation. // @@ -14,6 +16,10 @@ type ListCollectionsOptions struct { NameOnly *bool BatchSize *int32 AuthorizedCollections *bool + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // ListCollectionsOptionsBuilder contains options to configure list collection diff --git a/mongo/options/replaceoptions.go b/mongo/options/replaceoptions.go index 32caceff16..8b6c7e166d 100644 --- a/mongo/options/replaceoptions.go +++ b/mongo/options/replaceoptions.go @@ -6,6 +6,8 @@ package options +import "go.mongodb.org/mongo-driver/v2/internal/optionsutil" + // ReplaceOptions represents arguments that can be used to configure a ReplaceOne // operation. // @@ -18,6 +20,10 @@ type ReplaceOptions struct { Upsert *bool Let interface{} Sort interface{} + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // ReplaceOptionsBuilder contains options to configure replace operations. Each diff --git a/mongo/options/updateoptions.go b/mongo/options/updateoptions.go index f7b22e6f84..2a9f4f48d0 100644 --- a/mongo/options/updateoptions.go +++ b/mongo/options/updateoptions.go @@ -6,6 +6,8 @@ package options +import "go.mongodb.org/mongo-driver/v2/internal/optionsutil" + // UpdateOneOptions represents arguments that can be used to configure UpdateOne // operations. // @@ -19,6 +21,10 @@ type UpdateOneOptions struct { Upsert *bool Let interface{} Sort interface{} + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // UpdateOneOptionsBuilder contains options to configure UpdateOne operations. @@ -164,6 +170,10 @@ type UpdateManyOptions struct { Hint interface{} Upsert *bool Let interface{} + + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + Internal optionsutil.Options } // UpdateManyOptionsBuilder contains options to configure UpdateMany operations. diff --git a/testdata/specifications b/testdata/specifications index 668992950d..42b4f9e85f 160000 --- a/testdata/specifications +++ b/testdata/specifications @@ -1 +1 @@ -Subproject commit 668992950d975d3163e538849dd20383a214fc37 +Subproject commit 42b4f9e85f50c981ab1da56bedb2c2bd91d2f533 diff --git a/x/mongo/driver/operation/aggregate.go b/x/mongo/driver/operation/aggregate.go index a0cd5bd25e..380789ab04 100644 --- a/x/mongo/driver/operation/aggregate.go +++ b/x/mongo/driver/operation/aggregate.go @@ -50,6 +50,7 @@ type Aggregate struct { customOptions map[string]bsoncore.Value timeout *time.Duration omitMaxTimeMS bool + rawData *bool result driver.CursorResponse } @@ -159,6 +160,10 @@ func (a *Aggregate) command(dst []byte, desc description.SelectedServer) ([]byte if a.let != nil { dst = bsoncore.AppendDocumentElement(dst, "let", a.let) } + // Set rawData for 8.2+ servers. + if a.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *a.rawData) + } for optionName, optionValue := range a.customOptions { dst = bsoncore.AppendValueElement(dst, optionName, optionValue) } @@ -431,3 +436,13 @@ func (a *Aggregate) OmitMaxTimeMS(omit bool) *Aggregate { a.omitMaxTimeMS = omit return a } + +// RawData sets the rawData to access timeseries data in the compressed format. +func (a *Aggregate) RawData(rawData bool) *Aggregate { + if a == nil { + a = new(Aggregate) + } + + a.rawData = &rawData + return a +} diff --git a/x/mongo/driver/operation/count.go b/x/mongo/driver/operation/count.go index 5ecaa3a936..d056702aab 100644 --- a/x/mongo/driver/operation/count.go +++ b/x/mongo/driver/operation/count.go @@ -41,6 +41,7 @@ type Count struct { result CountResult serverAPI *driver.ServerAPIOptions timeout *time.Duration + rawData *bool } // CountResult represents a count result returned by the server. @@ -139,7 +140,7 @@ func (c *Count) Execute(ctx context.Context) error { return err } -func (c *Count) command(dst []byte, _ description.SelectedServer) ([]byte, error) { +func (c *Count) command(dst []byte, desc description.SelectedServer) ([]byte, error) { dst = bsoncore.AppendStringElement(dst, "count", c.collection) if c.query != nil { dst = bsoncore.AppendDocumentElement(dst, "query", c.query) @@ -147,6 +148,10 @@ func (c *Count) command(dst []byte, _ description.SelectedServer) ([]byte, error if c.comment.Type != bsoncore.Type(0) { dst = bsoncore.AppendValueElement(dst, "comment", c.comment) } + // Set rawData for 8.2+ servers. + if c.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *c.rawData) + } return dst, nil } @@ -310,3 +315,13 @@ func (c *Count) Authenticator(authenticator driver.Authenticator) *Count { c.authenticator = authenticator return c } + +// RawData sets the rawData to access timeseries data in the compressed format. +func (c *Count) RawData(rawData bool) *Count { + if c == nil { + c = new(Count) + } + + c.rawData = &rawData + return c +} diff --git a/x/mongo/driver/operation/create_indexes.go b/x/mongo/driver/operation/create_indexes.go index 0380a55a26..17e88ba8c8 100644 --- a/x/mongo/driver/operation/create_indexes.go +++ b/x/mongo/driver/operation/create_indexes.go @@ -38,6 +38,7 @@ type CreateIndexes struct { result CreateIndexesResult serverAPI *driver.ServerAPIOptions timeout *time.Duration + rawData *bool } // CreateIndexesResult represents a createIndexes result returned by the server. @@ -133,6 +134,10 @@ func (ci *CreateIndexes) command(dst []byte, desc description.SelectedServer) ([ if ci.indexes != nil { dst = bsoncore.AppendArrayElement(dst, "indexes", ci.indexes) } + // Set rawData for 8.2+ servers. + if ci.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *ci.rawData) + } return dst, nil } @@ -277,3 +282,13 @@ func (ci *CreateIndexes) Authenticator(authenticator driver.Authenticator) *Crea ci.authenticator = authenticator return ci } + +// RawData sets the rawData to access timeseries data in the compressed format. +func (ci *CreateIndexes) RawData(rawData bool) *CreateIndexes { + if ci == nil { + ci = new(CreateIndexes) + } + + ci.rawData = &rawData + return ci +} diff --git a/x/mongo/driver/operation/delete.go b/x/mongo/driver/operation/delete.go index e6f47042a8..e4510fb8fa 100644 --- a/x/mongo/driver/operation/delete.go +++ b/x/mongo/driver/operation/delete.go @@ -43,6 +43,7 @@ type Delete struct { serverAPI *driver.ServerAPIOptions let bsoncore.Document timeout *time.Duration + rawData *bool logger *logger.Logger } @@ -139,6 +140,10 @@ func (d *Delete) command(dst []byte, desc description.SelectedServer) ([]byte, e if d.let != nil { dst = bsoncore.AppendDocumentElement(dst, "let", d.let) } + // Set rawData for 8.2+ servers. + if d.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *d.rawData) + } return dst, nil } @@ -337,3 +342,13 @@ func (d *Delete) Authenticator(authenticator driver.Authenticator) *Delete { d.authenticator = authenticator return d } + +// RawData sets the rawData to access timeseries data in the compressed format. +func (d *Delete) RawData(rawData bool) *Delete { + if d == nil { + d = new(Delete) + } + + d.rawData = &rawData + return d +} diff --git a/x/mongo/driver/operation/distinct.go b/x/mongo/driver/operation/distinct.go index 89d412def3..ef235e2475 100644 --- a/x/mongo/driver/operation/distinct.go +++ b/x/mongo/driver/operation/distinct.go @@ -43,6 +43,7 @@ type Distinct struct { result DistinctResult serverAPI *driver.ServerAPIOptions timeout *time.Duration + rawData *bool } // DistinctResult represents a distinct result returned by the server. @@ -130,6 +131,10 @@ func (d *Distinct) command(dst []byte, desc description.SelectedServer) ([]byte, if d.query != nil { dst = bsoncore.AppendDocumentElement(dst, "query", d.query) } + // Set rawData for 8.2+ servers. + if d.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *d.rawData) + } return dst, nil } @@ -323,3 +328,13 @@ func (d *Distinct) Authenticator(authenticator driver.Authenticator) *Distinct { d.authenticator = authenticator return d } + +// RawData sets the rawData to access timeseries data in the compressed format. +func (d *Distinct) RawData(rawData bool) *Distinct { + if d == nil { + d = new(Distinct) + } + + d.rawData = &rawData + return d +} diff --git a/x/mongo/driver/operation/drop_indexes.go b/x/mongo/driver/operation/drop_indexes.go index e57cff72ee..14ecbdc1a9 100644 --- a/x/mongo/driver/operation/drop_indexes.go +++ b/x/mongo/driver/operation/drop_indexes.go @@ -37,6 +37,7 @@ type DropIndexes struct { result DropIndexesResult serverAPI *driver.ServerAPIOptions timeout *time.Duration + rawData *bool } // DropIndexesResult represents a dropIndexes result returned by the server. @@ -104,7 +105,7 @@ func (di *DropIndexes) Execute(ctx context.Context) error { } -func (di *DropIndexes) command(dst []byte, _ description.SelectedServer) ([]byte, error) { +func (di *DropIndexes) command(dst []byte, desc description.SelectedServer) ([]byte, error) { dst = bsoncore.AppendStringElement(dst, "dropIndexes", di.collection) switch t := di.index.(type) { @@ -115,6 +116,10 @@ func (di *DropIndexes) command(dst []byte, _ description.SelectedServer) ([]byte dst = bsoncore.AppendDocumentElement(dst, "index", t) } } + // Set rawData for 8.2+ servers. + if di.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *di.rawData) + } return dst, nil } @@ -248,3 +253,13 @@ func (di *DropIndexes) Authenticator(authenticator driver.Authenticator) *DropIn di.authenticator = authenticator return di } + +// RawData sets the rawData to access timeseries data in the compressed format. +func (di *DropIndexes) RawData(rawData bool) *DropIndexes { + if di == nil { + di = new(DropIndexes) + } + + di.rawData = &rawData + return di +} diff --git a/x/mongo/driver/operation/find.go b/x/mongo/driver/operation/find.go index b607cb14d7..615e240850 100644 --- a/x/mongo/driver/operation/find.go +++ b/x/mongo/driver/operation/find.go @@ -61,6 +61,7 @@ type Find struct { result driver.CursorResponse serverAPI *driver.ServerAPIOptions timeout *time.Duration + rawData *bool logger *logger.Logger omitMaxTimeMS bool } @@ -191,6 +192,10 @@ func (f *Find) command(dst []byte, desc description.SelectedServer) ([]byte, err if f.tailable != nil { dst = bsoncore.AppendBooleanElement(dst, "tailable", *f.tailable) } + // Set rawData for 8.2+ servers. + if f.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *f.rawData) + } return dst, nil } @@ -565,6 +570,16 @@ func (f *Find) Authenticator(authenticator driver.Authenticator) *Find { return f } +// RawData sets the rawData to access timeseries data in the compressed format. +func (f *Find) RawData(rawData bool) *Find { + if f == nil { + f = new(Find) + } + + f.rawData = &rawData + return f +} + // OmitMaxTimeMS omits the automatically-calculated "maxTimeMS" from the // command. func (f *Find) OmitMaxTimeMS(omit bool) *Find { diff --git a/x/mongo/driver/operation/find_and_modify.go b/x/mongo/driver/operation/find_and_modify.go index 9328a73ed5..0920568110 100644 --- a/x/mongo/driver/operation/find_and_modify.go +++ b/x/mongo/driver/operation/find_and_modify.go @@ -50,6 +50,7 @@ type FindAndModify struct { serverAPI *driver.ServerAPIOptions let bsoncore.Document timeout *time.Duration + rawData *bool result FindAndModifyResult } @@ -211,6 +212,10 @@ func (fam *FindAndModify) command(dst []byte, desc description.SelectedServer) ( if fam.let != nil { dst = bsoncore.AppendDocumentElement(dst, "let", fam.let) } + // Set rawData for 8.2+ servers. + if fam.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *fam.rawData) + } return dst, nil } @@ -476,3 +481,13 @@ func (fam *FindAndModify) Authenticator(authenticator driver.Authenticator) *Fin fam.authenticator = authenticator return fam } + +// RawData sets the rawData to access timeseries data in the compressed format. +func (fam *FindAndModify) RawData(rawData bool) *FindAndModify { + if fam == nil { + fam = new(FindAndModify) + } + + fam.rawData = &rawData + return fam +} diff --git a/x/mongo/driver/operation/insert.go b/x/mongo/driver/operation/insert.go index b48e2c85f3..57d461ae3b 100644 --- a/x/mongo/driver/operation/insert.go +++ b/x/mongo/driver/operation/insert.go @@ -42,6 +42,7 @@ type Insert struct { result InsertResult serverAPI *driver.ServerAPIOptions timeout *time.Duration + rawData *bool logger *logger.Logger } @@ -132,6 +133,10 @@ func (i *Insert) command(dst []byte, desc description.SelectedServer) ([]byte, e if i.ordered != nil { dst = bsoncore.AppendBooleanElement(dst, "ordered", *i.ordered) } + // Set rawData for 8.2+ servers. + if i.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *i.rawData) + } return dst, nil } @@ -318,3 +323,13 @@ func (i *Insert) Authenticator(authenticator driver.Authenticator) *Insert { i.authenticator = authenticator return i } + +// RawData sets the rawData to access timeseries data in the compressed format. +func (i *Insert) RawData(rawData bool) *Insert { + if i == nil { + i = new(Insert) + } + + i.rawData = &rawData + return i +} diff --git a/x/mongo/driver/operation/list_collections.go b/x/mongo/driver/operation/list_collections.go index 3f9b55a6c3..672404cb0b 100644 --- a/x/mongo/driver/operation/list_collections.go +++ b/x/mongo/driver/operation/list_collections.go @@ -39,6 +39,7 @@ type ListCollections struct { batchSize *int32 serverAPI *driver.ServerAPIOptions timeout *time.Duration + rawData *bool } // NewListCollections constructs and returns a new ListCollections. @@ -92,7 +93,7 @@ func (lc *ListCollections) Execute(ctx context.Context) error { } -func (lc *ListCollections) command(dst []byte, _ description.SelectedServer) ([]byte, error) { +func (lc *ListCollections) command(dst []byte, desc description.SelectedServer) ([]byte, error) { dst = bsoncore.AppendInt32Element(dst, "listCollections", 1) if lc.filter != nil { dst = bsoncore.AppendDocumentElement(dst, "filter", lc.filter) @@ -110,6 +111,11 @@ func (lc *ListCollections) command(dst []byte, _ description.SelectedServer) ([] } dst = bsoncore.AppendDocumentElement(dst, "cursor", cursorDoc.Build()) + // Set rawData for 8.2+ servers. + if lc.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *lc.rawData) + } + return dst, nil } @@ -274,3 +280,13 @@ func (lc *ListCollections) Authenticator(authenticator driver.Authenticator) *Li lc.authenticator = authenticator return lc } + +// RawData sets the rawData to access timeseries data in the compressed format. +func (lc *ListCollections) RawData(rawData bool) *ListCollections { + if lc == nil { + lc = new(ListCollections) + } + + lc.rawData = &rawData + return lc +} diff --git a/x/mongo/driver/operation/list_indexes.go b/x/mongo/driver/operation/list_indexes.go index d7642a19e1..21b138a40c 100644 --- a/x/mongo/driver/operation/list_indexes.go +++ b/x/mongo/driver/operation/list_indexes.go @@ -34,6 +34,7 @@ type ListIndexes struct { crypt driver.Crypt serverAPI *driver.ServerAPIOptions timeout *time.Duration + rawData *bool result driver.CursorResponse } @@ -91,16 +92,19 @@ func (li *ListIndexes) Execute(ctx context.Context) error { } -func (li *ListIndexes) command(dst []byte, _ description.SelectedServer) ([]byte, error) { +func (li *ListIndexes) command(dst []byte, desc description.SelectedServer) ([]byte, error) { dst = bsoncore.AppendStringElement(dst, "listIndexes", li.collection) cursorIdx, cursorDoc := bsoncore.AppendDocumentStart(nil) if li.batchSize != nil { - cursorDoc = bsoncore.AppendInt32Element(cursorDoc, "batchSize", *li.batchSize) } cursorDoc, _ = bsoncore.AppendDocumentEnd(cursorDoc, cursorIdx) dst = bsoncore.AppendDocumentElement(dst, "cursor", cursorDoc) + // Set rawData for 8.2+ servers. + if li.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *li.rawData) + } return dst, nil } @@ -235,3 +239,13 @@ func (li *ListIndexes) Authenticator(authenticator driver.Authenticator) *ListIn li.authenticator = authenticator return li } + +// RawData sets the rawData to access timeseries data in the compressed format. +func (li *ListIndexes) RawData(rawData bool) *ListIndexes { + if li == nil { + li = new(ListIndexes) + } + + li.rawData = &rawData + return li +} diff --git a/x/mongo/driver/operation/update.go b/x/mongo/driver/operation/update.go index 6e6222f2f4..00e193ef49 100644 --- a/x/mongo/driver/operation/update.go +++ b/x/mongo/driver/operation/update.go @@ -46,6 +46,7 @@ type Update struct { serverAPI *driver.ServerAPIOptions let bsoncore.Document timeout *time.Duration + rawData *bool logger *logger.Logger } @@ -203,6 +204,10 @@ func (u *Update) command(dst []byte, desc description.SelectedServer) ([]byte, e if u.let != nil { dst = bsoncore.AppendDocumentElement(dst, "let", u.let) } + // Set rawData for 8.2+ servers. + if u.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *u.rawData) + } return dst, nil } @@ -422,3 +427,13 @@ func (u *Update) Authenticator(authenticator driver.Authenticator) *Update { u.authenticator = authenticator return u } + +// RawData sets the rawData to access timeseries data in the compressed format. +func (u *Update) RawData(rawData bool) *Update { + if u == nil { + u = new(Update) + } + + u.rawData = &rawData + return u +} diff --git a/x/mongo/driver/xoptions/options.go b/x/mongo/driver/xoptions/options.go index 68e28e7cd8..fa11dd60b8 100644 --- a/x/mongo/driver/xoptions/options.go +++ b/x/mongo/driver/xoptions/options.go @@ -15,11 +15,9 @@ import ( ) // SetInternalClientOptions sets internal options for ClientOptions. -// -// Deprecated: This function is for internal use only. It may be changed or removed in any release. func SetInternalClientOptions(opts *options.ClientOptions, key string, option any) error { typeErrFunc := func(t string) error { - return fmt.Errorf("unexpected type for %s: %T is not %s", key, option, t) + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) } switch key { case "crypt": @@ -41,7 +39,469 @@ func SetInternalClientOptions(opts *options.ClientOptions, key string, option an } opts.Custom = optionsutil.WithValue(opts.Custom, key, b) default: - return fmt.Errorf("unsupported option: %s", key) + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalAggregateOptions sets internal options for AggregateOptions. +func SetInternalAggregateOptions(a *options.AggregateOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.AggregateOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalBulkWriteOptions sets internal options for BulkWriteOptions. +func SetInternalBulkWriteOptions(a *options.BulkWriteOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.BulkWriteOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalClientBulkWriteOptions sets internal options for ClientBulkWriteOptions. +func SetInternalClientBulkWriteOptions(a *options.ClientBulkWriteOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.ClientBulkWriteOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalCountOptions sets internal options for CountOptions. +func SetInternalCountOptions(a *options.CountOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.CountOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalCreateIndexesOptions sets internal options for CreateIndexesOptions. +func SetInternalCreateIndexesOptions(a *options.CreateIndexesOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.CreateIndexesOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalDeleteOneOptions sets internal options for DeleteOneOptions. +func SetInternalDeleteOneOptions(a *options.DeleteOneOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.DeleteOneOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalDeleteManyOptions sets internal options for DeleteManyOptions. +func SetInternalDeleteManyOptions(a *options.DeleteManyOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.DeleteManyOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalDistinctOptions sets internal options for DistinctOptions. +func SetInternalDistinctOptions(a *options.DistinctOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.DistinctOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalDropIndexesOptions sets internal options for DropIndexesOptions. +func SetInternalDropIndexesOptions(a *options.DropIndexesOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.DropIndexesOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalEstimatedDocumentCountOptions sets internal options for EstimatedDocumentCountOptions. +func SetInternalEstimatedDocumentCountOptions(a *options.EstimatedDocumentCountOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.EstimatedDocumentCountOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalFindOptions sets internal options for FindOptions. +func SetInternalFindOptions(a *options.FindOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.FindOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalFindOneOptions sets internal options for FindOneOptions. +func SetInternalFindOneOptions(a *options.FindOneOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.FindOneOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalFindOneAndDeleteOptions sets internal options for FindOneAndDeleteOptions. +func SetInternalFindOneAndDeleteOptions(a *options.FindOneAndDeleteOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.FindOneAndDeleteOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalFindOneAndReplaceOptions sets internal options for FindOneAndReplaceOptions. +func SetInternalFindOneAndReplaceOptions(a *options.FindOneAndReplaceOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.FindOneAndReplaceOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalFindOneAndUpdateOptions sets internal options for FindOneAndUpdateOptions. +func SetInternalFindOneAndUpdateOptions(a *options.FindOneAndUpdateOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.FindOneAndUpdateOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalInsertManyOptions sets internal options for InsertManyOptions. +func SetInternalInsertManyOptions(a *options.InsertManyOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.InsertManyOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalInsertOneOptions sets internal options for InsertOneOptions. +func SetInternalInsertOneOptions(a *options.InsertOneOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.InsertOneOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalListCollectionsOptions sets internal options for ListCollectionsOptions. +func SetInternalListCollectionsOptions(a *options.ListCollectionsOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.ListCollectionsOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalListIndexesOptions sets internal options for ListIndexesOptions. +func SetInternalListIndexesOptions(a *options.ListIndexesOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.ListIndexesOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalReplaceOptions sets internal options for ReplaceOptions. +func SetInternalReplaceOptions(a *options.ReplaceOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.ReplaceOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalUpdateManyOptions sets internal options for UpdateManyOptions. +func SetInternalUpdateManyOptions(a *options.UpdateManyOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.UpdateManyOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) + } + return nil +} + +// SetInternalUpdateOneOptions sets internal options for UpdateOneOptions. +func SetInternalUpdateOneOptions(a *options.UpdateOneOptionsBuilder, key string, option any) error { + typeErrFunc := func(t string) error { + return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t) + } + switch key { + case "rawData": + b, ok := option.(bool) + if !ok { + return typeErrFunc("bool") + } + a.Opts = append(a.Opts, func(opts *options.UpdateOneOptions) error { + opts.Internal = optionsutil.WithValue(opts.Internal, key, b) + return nil + }) + default: + return fmt.Errorf("unsupported option: %q", key) } return nil } diff --git a/x/mongo/driver/xoptions/options_test.go b/x/mongo/driver/xoptions/options_test.go index 284fe914a1..4a4e1a371e 100644 --- a/x/mongo/driver/xoptions/options_test.go +++ b/x/mongo/driver/xoptions/options_test.go @@ -58,7 +58,7 @@ func TestSetInternalClientOptions(t *testing.T) { opts := options.Client() err := SetInternalClientOptions(opts, "crypt", &drivertest.MockDeployment{}) - require.EqualError(t, err, "unexpected type for crypt: *drivertest.MockDeployment is not driver.Crypt") + require.EqualError(t, err, "unexpected type for \"crypt\": *drivertest.MockDeployment is not driver.Crypt") }) t.Run("set deployment", func(t *testing.T) { @@ -76,7 +76,7 @@ func TestSetInternalClientOptions(t *testing.T) { opts := options.Client() err := SetInternalClientOptions(opts, "deployment", driver.NewCrypt(&driver.CryptOptions{})) - require.EqualError(t, err, "unexpected type for deployment: *driver.crypt is not driver.Deployment") + require.EqualError(t, err, "unexpected type for \"deployment\": *driver.crypt is not driver.Deployment") }) t.Run("set unsupported option", func(t *testing.T) { @@ -84,6 +84,6 @@ func TestSetInternalClientOptions(t *testing.T) { opts := options.Client() err := SetInternalClientOptions(opts, "unsupported", "unsupported") - require.EqualError(t, err, "unsupported option: unsupported") + require.EqualError(t, err, "unsupported option: \"unsupported\"") }) }