Skip to content

Commit efcef13

Browse files
committed
make rawDate internal
1 parent 61ee9f8 commit efcef13

File tree

10 files changed

+174
-79
lines changed

10 files changed

+174
-79
lines changed

internal/integration/unified/client_operation_execution.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"go.mongodb.org/mongo-driver/v2/mongo"
2020
"go.mongodb.org/mongo-driver/v2/mongo/options"
2121
"go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore"
22+
"go.mongodb.org/mongo-driver/v2/x/mongo/driver/xoptions"
2223
)
2324

2425
// This file contains helpers to execute client operations.
@@ -236,7 +237,10 @@ func executeClientBulkWrite(ctx context.Context, operation *operation) (*operati
236237
}
237238
opts.SetWriteConcern(c)
238239
case "rawData":
239-
opts.SetRawData(val.Boolean())
240+
err = xoptions.SetInternalClientBulkWriteOptions(opts, key, val.Boolean())
241+
if err != nil {
242+
return nil, err
243+
}
240244
default:
241245
return nil, fmt.Errorf("unrecognized bulkWrite option %q", key)
242246
}

internal/integration/unified/collection_operation_execution.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,10 @@ func executeCreateIndex(ctx context.Context, operation *operation) (*operationRe
297297
case "wildcardProjection":
298298
indexOpts.SetWildcardProjection(val.Document())
299299
case "rawData":
300-
opts.SetRawData(val.Boolean())
300+
err = xoptions.SetInternalCreateIndexesOptions(opts, key, val.Boolean())
301+
if err != nil {
302+
return nil, err
303+
}
301304
default:
302305
return nil, fmt.Errorf("unrecognized createIndex option %q", key)
303306
}
@@ -629,7 +632,10 @@ func executeDropIndex(ctx context.Context, operation *operation) (*operationResu
629632
// this error.
630633
return nil, fmt.Errorf("the maxTimeMS collection option is not supported")
631634
case "rawData":
632-
dropIndexOpts.SetRawData(val.Boolean())
635+
err = xoptions.SetInternalDropIndexesOptions(dropIndexOpts, key, val.Boolean())
636+
if err != nil {
637+
return nil, err
638+
}
633639
default:
634640
return nil, fmt.Errorf("unrecognized dropIndex option %q", key)
635641
}
@@ -1224,7 +1230,10 @@ func executeListIndexes(ctx context.Context, operation *operation) (*operationRe
12241230
case "batchSize":
12251231
opts.SetBatchSize(val.Int32())
12261232
case "rawData":
1227-
opts.SetRawData(val.Boolean())
1233+
err = xoptions.SetInternalListIndexesOptions(opts, key, val.Boolean())
1234+
if err != nil {
1235+
return nil, err
1236+
}
12281237
default:
12291238
return nil, fmt.Errorf("unrecognized listIndexes option: %q", key)
12301239
}

internal/integration/unified/crud_helpers.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,10 @@ func createListCollectionsArguments(args bson.Raw) (*listCollectionsArguments, e
174174
case "nameOnly":
175175
lca.opts.SetNameOnly(val.Boolean())
176176
case "rawData":
177-
lca.opts.SetRawData(val.Boolean())
177+
err := xoptions.SetInternalListCollectionsOptions(lca.opts, key, val.Boolean())
178+
if err != nil {
179+
return nil, err
180+
}
178181
default:
179182
return nil, fmt.Errorf("unrecognized listCollections option %q", key)
180183
}

mongo/client.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"go.mongodb.org/mongo-driver/v2/internal/httputil"
1919
"go.mongodb.org/mongo-driver/v2/internal/logger"
2020
"go.mongodb.org/mongo-driver/v2/internal/mongoutil"
21+
"go.mongodb.org/mongo-driver/v2/internal/optionsutil"
2122
"go.mongodb.org/mongo-driver/v2/internal/ptrutil"
2223
"go.mongodb.org/mongo-driver/v2/internal/serverselector"
2324
"go.mongodb.org/mongo-driver/v2/internal/uuid"
@@ -956,7 +957,11 @@ func (c *Client) BulkWrite(ctx context.Context, writes []ClientBulkWrite,
956957
client: c,
957958
selector: selector,
958959
writeConcern: wc,
959-
rawData: bwo.RawData,
960+
}
961+
if rawDataOpt := optionsutil.Value(bwo.Internal, "rawData"); rawDataOpt != nil {
962+
if rawData, ok := rawDataOpt.(bool); ok {
963+
op.rawData = &rawData
964+
}
960965
}
961966
if bwo.VerboseResults == nil || !(*bwo.VerboseResults) {
962967
op.errorsOnly = true

mongo/database.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"go.mongodb.org/mongo-driver/v2/internal/csfle"
1717
"go.mongodb.org/mongo-driver/v2/internal/csot"
1818
"go.mongodb.org/mongo-driver/v2/internal/mongoutil"
19+
"go.mongodb.org/mongo-driver/v2/internal/optionsutil"
1920
"go.mongodb.org/mongo-driver/v2/internal/serverselector"
2021
"go.mongodb.org/mongo-driver/v2/mongo/options"
2122
"go.mongodb.org/mongo-driver/v2/mongo/readconcern"
@@ -487,8 +488,10 @@ func (db *Database) ListCollections(
487488
if args.AuthorizedCollections != nil {
488489
op = op.AuthorizedCollections(*args.AuthorizedCollections)
489490
}
490-
if args.RawData != nil {
491-
op = op.RawData(*args.RawData)
491+
if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil {
492+
if rawData, ok := rawDataOpt.(bool); ok {
493+
op = op.RawData(rawData)
494+
}
492495
}
493496

494497
retry := driver.RetryNone

mongo/index_view.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"strconv"
1515

1616
"go.mongodb.org/mongo-driver/v2/internal/mongoutil"
17+
"go.mongodb.org/mongo-driver/v2/internal/optionsutil"
1718
"go.mongodb.org/mongo-driver/v2/internal/serverselector"
1819
"go.mongodb.org/mongo-driver/v2/mongo/options"
1920
"go.mongodb.org/mongo-driver/v2/mongo/readpref"
@@ -101,8 +102,10 @@ func (iv IndexView) List(ctx context.Context, opts ...options.Lister[options.Lis
101102
op = op.BatchSize(*args.BatchSize)
102103
cursorOpts.BatchSize = *args.BatchSize
103104
}
104-
if args.RawData != nil {
105-
op = op.RawData(*args.RawData)
105+
if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil {
106+
if rawData, ok := rawDataOpt.(bool); ok {
107+
op = op.RawData(rawData)
108+
}
106109
}
107110

108111
retry := driver.RetryNone
@@ -282,8 +285,10 @@ func (iv IndexView) CreateMany(
282285

283286
op.CommitQuorum(commitQuorum)
284287
}
285-
if args.RawData != nil {
286-
op = op.RawData(*args.RawData)
288+
if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil {
289+
if rawData, ok := rawDataOpt.(bool); ok {
290+
op = op.RawData(rawData)
291+
}
287292
}
288293

289294
_, err = processWriteError(op.Execute(ctx))
@@ -419,8 +424,10 @@ func (iv IndexView) drop(ctx context.Context, index any, opts ...options.Lister[
419424
Deployment(iv.coll.client.deployment).ServerAPI(iv.coll.client.serverAPI).
420425
Timeout(iv.coll.client.timeout).Crypt(iv.coll.client.cryptFLE).Authenticator(iv.coll.client.authenticator)
421426

422-
if args.RawData != nil {
423-
op = op.RawData(*args.RawData)
427+
if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil {
428+
if rawData, ok := rawDataOpt.(bool); ok {
429+
op = op.RawData(rawData)
430+
}
424431
}
425432

426433
err = op.Execute(ctx)

mongo/options/clientbulkwriteoptions.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package options
88

99
import (
10+
"go.mongodb.org/mongo-driver/v2/internal/optionsutil"
1011
"go.mongodb.org/mongo-driver/v2/mongo/writeconcern"
1112
)
1213

@@ -19,8 +20,11 @@ type ClientBulkWriteOptions struct {
1920
Ordered *bool
2021
Let interface{}
2122
WriteConcern *writeconcern.WriteConcern
22-
RawData *bool
2323
VerboseResults *bool
24+
25+
// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any
26+
// release.
27+
Internal optionsutil.Options
2428
}
2529

2630
// ClientBulkWriteOptionsBuilder contains options to configure client-level bulk
@@ -109,18 +113,6 @@ func (b *ClientBulkWriteOptionsBuilder) SetWriteConcern(wc *writeconcern.WriteCo
109113
return b
110114
}
111115

112-
// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries
113-
// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false.
114-
func (b *ClientBulkWriteOptionsBuilder) SetRawData(rawData bool) *ClientBulkWriteOptionsBuilder {
115-
b.Opts = append(b.Opts, func(opts *ClientBulkWriteOptions) error {
116-
opts.RawData = &rawData
117-
118-
return nil
119-
})
120-
121-
return b
122-
}
123-
124116
// SetVerboseResults sets the value for the VerboseResults field. Specifies whether detailed
125117
// results for each successful operation should be included in the returned BulkWriteResult.
126118
// The defaults value is false.

mongo/options/indexoptions.go

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@
66

77
package options
88

9+
import "go.mongodb.org/mongo-driver/v2/internal/optionsutil"
10+
911
// CreateIndexesOptions represents arguments that can be used to configure
1012
// IndexView.CreateOne and IndexView.CreateMany operations.
1113
//
1214
// See corresponding setter methods for documentation.
1315
type CreateIndexesOptions struct {
1416
CommitQuorum interface{}
15-
RawData *bool
17+
18+
// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any
19+
// release.
20+
Internal optionsutil.Options
1621
}
1722

1823
// CreateIndexesOptionsBuilder contains options to create indexes. Each option
@@ -120,22 +125,12 @@ func (c *CreateIndexesOptionsBuilder) SetCommitQuorumVotingMembers() *CreateInde
120125
return c
121126
}
122127

123-
// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries
124-
// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false.
125-
func (c *CreateIndexesOptionsBuilder) SetRawData(rawData bool) *CreateIndexesOptionsBuilder {
126-
c.Opts = append(c.Opts, func(opts *CreateIndexesOptions) error {
127-
opts.RawData = &rawData
128-
129-
return nil
130-
})
131-
132-
return c
133-
}
134-
135128
// DropIndexesOptions represents arguments that can be used to configure
136129
// IndexView.DropOne and IndexView.DropAll operations.
137130
type DropIndexesOptions struct {
138-
RawData *bool
131+
// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any
132+
// release.
133+
Internal optionsutil.Options
139134
}
140135

141136
// DropIndexesOptionsBuilder contains options to configure dropping indexes.
@@ -155,25 +150,16 @@ func (d *DropIndexesOptionsBuilder) List() []func(*DropIndexesOptions) error {
155150
return d.Opts
156151
}
157152

158-
// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries
159-
// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false.
160-
func (d *DropIndexesOptionsBuilder) SetRawData(rawData bool) *DropIndexesOptionsBuilder {
161-
d.Opts = append(d.Opts, func(opts *DropIndexesOptions) error {
162-
opts.RawData = &rawData
163-
164-
return nil
165-
})
166-
167-
return d
168-
}
169-
170153
// ListIndexesOptions represents arguments that can be used to configure an
171154
// IndexView.List operation.
172155
//
173156
// See corresponding setter methods for documentation.
174157
type ListIndexesOptions struct {
175158
BatchSize *int32
176-
RawData *bool
159+
160+
// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any
161+
// release.
162+
Internal optionsutil.Options
177163
}
178164

179165
// ListIndexesOptionsBuilder contains options to configure count operations. Each
@@ -205,18 +191,6 @@ func (l *ListIndexesOptionsBuilder) SetBatchSize(i int32) *ListIndexesOptionsBui
205191
return l
206192
}
207193

208-
// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries
209-
// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false.
210-
func (l *ListIndexesOptionsBuilder) SetRawData(rawData bool) *ListIndexesOptionsBuilder {
211-
l.Opts = append(l.Opts, func(opts *ListIndexesOptions) error {
212-
opts.RawData = &rawData
213-
214-
return nil
215-
})
216-
217-
return l
218-
}
219-
220194
// IndexOptions represents arguments that can be used to configure a new index
221195
// created through the IndexView.CreateOne or IndexView.CreateMany operations.
222196
//

mongo/options/listcollectionsoptions.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
package options
88

9+
import "go.mongodb.org/mongo-driver/v2/internal/optionsutil"
10+
911
// ListCollectionsOptions represents arguments that can be used to configure a
1012
// ListCollections operation.
1113
//
@@ -14,7 +16,10 @@ type ListCollectionsOptions struct {
1416
NameOnly *bool
1517
BatchSize *int32
1618
AuthorizedCollections *bool
17-
RawData *bool
19+
20+
// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any
21+
// release.
22+
Internal optionsutil.Options
1823
}
1924

2025
// ListCollectionsOptionsBuilder contains options to configure list collection
@@ -71,15 +76,3 @@ func (lc *ListCollectionsOptionsBuilder) SetAuthorizedCollections(b bool) *ListC
7176

7277
return lc
7378
}
74-
75-
// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries
76-
// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false.
77-
func (lc *ListCollectionsOptionsBuilder) SetRawData(rawData bool) *ListCollectionsOptionsBuilder {
78-
lc.Opts = append(lc.Opts, func(opts *ListCollectionsOptions) error {
79-
opts.RawData = &rawData
80-
81-
return nil
82-
})
83-
84-
return lc
85-
}

0 commit comments

Comments
 (0)