Skip to content

Commit 53f0226

Browse files
committed
Rename custom options fields
1 parent 6a2e0d4 commit 53f0226

File tree

9 files changed

+31
-31
lines changed

9 files changed

+31
-31
lines changed

mongo/collection.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ func (coll *Collection) insert(
325325
if args.Ordered != nil {
326326
op = op.Ordered(*args.Ordered)
327327
}
328-
if rawDataOpt := optionsutil.Value(args.CustomOptions, "rawData"); rawDataOpt != nil {
328+
if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil {
329329
if rawData, ok := rawDataOpt.(bool); ok {
330330
op = op.RawData(rawData)
331331
}
@@ -381,9 +381,9 @@ func (coll *Collection) InsertOne(ctx context.Context, document interface{},
381381
if args.Comment != nil {
382382
imOpts.SetComment(args.Comment)
383383
}
384-
if rawDataOpt := optionsutil.Value(args.CustomOptions, "rawData"); rawDataOpt != nil {
384+
if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil {
385385
imOpts.Opts = append(imOpts.Opts, func(opts *options.InsertManyOptions) error {
386-
optionsutil.WithValue(opts.CustomOptions, "rawData", rawDataOpt)
386+
optionsutil.WithValue(opts.Internal, "rawData", rawDataOpt)
387387

388388
return nil
389389
})
@@ -547,7 +547,7 @@ func (coll *Collection) delete(
547547
}
548548
op = op.Let(let)
549549
}
550-
if rawDataOpt := optionsutil.Value(args.CustomOptions, "rawData"); rawDataOpt != nil {
550+
if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil {
551551
if rawData, ok := rawDataOpt.(bool); ok {
552552
op = op.RawData(rawData)
553553
}
@@ -589,11 +589,11 @@ func (coll *Collection) DeleteOne(
589589
return nil, fmt.Errorf("failed to construct options from builder: %w", err)
590590
}
591591
deleteOptions := &options.DeleteManyOptions{
592-
Collation: args.Collation,
593-
Comment: args.Comment,
594-
Hint: args.Hint,
595-
Let: args.Let,
596-
CustomOptions: args.CustomOptions,
592+
Collation: args.Collation,
593+
Comment: args.Comment,
594+
Hint: args.Hint,
595+
Let: args.Let,
596+
Internal: args.Internal,
597597
}
598598

599599
return coll.delete(ctx, filter, true, rrOne, deleteOptions)
@@ -1055,7 +1055,7 @@ func aggregate(a aggregateParams, opts ...options.Lister[options.AggregateOption
10551055
}
10561056
op.CustomOptions(customOptions)
10571057
}
1058-
if rawDataOpt := optionsutil.Value(args.CustomOptions, "rawData"); rawDataOpt != nil {
1058+
if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil {
10591059
if rawData, ok := rawDataOpt.(bool); ok {
10601060
op = op.RawData(rawData)
10611061
}
@@ -1148,7 +1148,7 @@ func (coll *Collection) CountDocuments(ctx context.Context, filter interface{},
11481148
}
11491149
op.Hint(hintVal)
11501150
}
1151-
if rawDataOpt := optionsutil.Value(args.CustomOptions, "rawData"); rawDataOpt != nil {
1151+
if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil {
11521152
if rawData, ok := rawDataOpt.(bool); ok {
11531153
op = op.RawData(rawData)
11541154
}
@@ -1234,7 +1234,7 @@ func (coll *Collection) EstimatedDocumentCount(
12341234
}
12351235
op = op.Comment(comment)
12361236
}
1237-
if rawDataOpt := optionsutil.Value(args.CustomOptions, "rawData"); rawDataOpt != nil {
1237+
if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil {
12381238
if rawData, ok := rawDataOpt.(bool); ok {
12391239
op = op.RawData(rawData)
12401240
}
@@ -1328,7 +1328,7 @@ func (coll *Collection) Distinct(
13281328
}
13291329
op.Hint(hint)
13301330
}
1331-
if rawDataOpt := optionsutil.Value(args.CustomOptions, "rawData"); rawDataOpt != nil {
1331+
if rawDataOpt := optionsutil.Value(args.Internal, "rawData"); rawDataOpt != nil {
13321332
if rawData, ok := rawDataOpt.(bool); ok {
13331333
op = op.RawData(rawData)
13341334
}

mongo/options/aggregateoptions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type AggregateOptions struct {
3030

3131
// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any
3232
// release.
33-
CustomOptions optionsutil.Options
33+
Internal optionsutil.Options
3434
}
3535

3636
// AggregateOptionsBuilder contains options to configure aggregate operations.

mongo/options/countoptions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type CountOptions struct {
2121

2222
// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any
2323
// release.
24-
CustomOptions optionsutil.Options
24+
Internal optionsutil.Options
2525
}
2626

2727
// CountOptionsBuilder contains options to configure count operations. Each

mongo/options/deleteoptions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type DeleteOneOptions struct {
2020

2121
// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any
2222
// release.
23-
CustomOptions optionsutil.Options
23+
Internal optionsutil.Options
2424
}
2525

2626
// DeleteOneOptionsBuilder contains options to configure DeleteOne operations. Each
@@ -111,7 +111,7 @@ type DeleteManyOptions struct {
111111

112112
// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any
113113
// release.
114-
CustomOptions optionsutil.Options
114+
Internal optionsutil.Options
115115
}
116116

117117
// DeleteManyOptionsBuilder contains options to configure DeleteMany operations.

mongo/options/distinctoptions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type DistinctOptions struct {
1919

2020
// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any
2121
// release.
22-
CustomOptions optionsutil.Options
22+
Internal optionsutil.Options
2323
}
2424

2525
// DistinctOptionsBuilder contains options to configure distinct operations. Each

mongo/options/estimatedcountoptions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type EstimatedDocumentCountOptions struct {
1717

1818
// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any
1919
// release.
20-
CustomOptions optionsutil.Options
20+
Internal optionsutil.Options
2121
}
2222

2323
// EstimatedDocumentCountOptionsBuilder contains options to estimate document

mongo/options/insertoptions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type InsertOneOptions struct {
1818

1919
// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any
2020
// release.
21-
CustomOptions optionsutil.Options
21+
Internal optionsutil.Options
2222
}
2323

2424
// InsertOneOptionsBuilder represents functional options that configure an
@@ -70,7 +70,7 @@ type InsertManyOptions struct {
7070

7171
// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any
7272
// release.
73-
CustomOptions optionsutil.Options
73+
Internal optionsutil.Options
7474
}
7575

7676
// InsertManyOptionsBuilder contains options to configure insert operations.

x/mongo/driver/xoptions/options.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func SetInternalAggregateOptions(a *options.AggregateOptionsBuilder, key string,
5656
return typeErrFunc("bool")
5757
}
5858
a.Opts = append(a.Opts, func(opts *options.AggregateOptions) error {
59-
opts.CustomOptions = optionsutil.WithValue(opts.CustomOptions, key, b)
59+
opts.Internal = optionsutil.WithValue(opts.Internal, key, b)
6060
return nil
6161
})
6262
default:
@@ -77,7 +77,7 @@ func SetInternalCountOptions(a *options.CountOptionsBuilder, key string, option
7777
return typeErrFunc("bool")
7878
}
7979
a.Opts = append(a.Opts, func(opts *options.CountOptions) error {
80-
opts.CustomOptions = optionsutil.WithValue(opts.CustomOptions, key, b)
80+
opts.Internal = optionsutil.WithValue(opts.Internal, key, b)
8181
return nil
8282
})
8383
default:
@@ -98,7 +98,7 @@ func SetInternalDeleteOneOptions(a *options.DeleteOneOptionsBuilder, key string,
9898
return typeErrFunc("bool")
9999
}
100100
a.Opts = append(a.Opts, func(opts *options.DeleteOneOptions) error {
101-
opts.CustomOptions = optionsutil.WithValue(opts.CustomOptions, key, b)
101+
opts.Internal = optionsutil.WithValue(opts.Internal, key, b)
102102
return nil
103103
})
104104
default:
@@ -119,7 +119,7 @@ func SetInternalDeleteManyOptions(a *options.DeleteManyOptionsBuilder, key strin
119119
return typeErrFunc("bool")
120120
}
121121
a.Opts = append(a.Opts, func(opts *options.DeleteManyOptions) error {
122-
opts.CustomOptions = optionsutil.WithValue(opts.CustomOptions, key, b)
122+
opts.Internal = optionsutil.WithValue(opts.Internal, key, b)
123123
return nil
124124
})
125125
default:
@@ -140,7 +140,7 @@ func SetInternalDistinctOptions(a *options.DistinctOptionsBuilder, key string, o
140140
return typeErrFunc("bool")
141141
}
142142
a.Opts = append(a.Opts, func(opts *options.DistinctOptions) error {
143-
opts.CustomOptions = optionsutil.WithValue(opts.CustomOptions, key, b)
143+
opts.Internal = optionsutil.WithValue(opts.Internal, key, b)
144144
return nil
145145
})
146146
default:
@@ -161,7 +161,7 @@ func SetInternalEstimatedDocumentCountOptions(a *options.EstimatedDocumentCountO
161161
return typeErrFunc("bool")
162162
}
163163
a.Opts = append(a.Opts, func(opts *options.EstimatedDocumentCountOptions) error {
164-
opts.CustomOptions = optionsutil.WithValue(opts.CustomOptions, key, b)
164+
opts.Internal = optionsutil.WithValue(opts.Internal, key, b)
165165
return nil
166166
})
167167
default:
@@ -182,7 +182,7 @@ func SetInternalInsertManyOptions(a *options.InsertManyOptionsBuilder, key strin
182182
return typeErrFunc("bool")
183183
}
184184
a.Opts = append(a.Opts, func(opts *options.InsertManyOptions) error {
185-
opts.CustomOptions = optionsutil.WithValue(opts.CustomOptions, key, b)
185+
opts.Internal = optionsutil.WithValue(opts.Internal, key, b)
186186
return nil
187187
})
188188
default:
@@ -203,7 +203,7 @@ func SetInternalInsertOneOptions(a *options.InsertOneOptionsBuilder, key string,
203203
return typeErrFunc("bool")
204204
}
205205
a.Opts = append(a.Opts, func(opts *options.InsertOneOptions) error {
206-
opts.CustomOptions = optionsutil.WithValue(opts.CustomOptions, key, b)
206+
opts.Internal = optionsutil.WithValue(opts.Internal, key, b)
207207
return nil
208208
})
209209
default:

x/mongo/driver/xoptions/options_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func TestSetInternalClientOptions(t *testing.T) {
5858

5959
opts := options.Client()
6060
err := SetInternalClientOptions(opts, "crypt", &drivertest.MockDeployment{})
61-
require.EqualError(t, err, "unexpected type for crypt: *drivertest.MockDeployment is not driver.Crypt")
61+
require.EqualError(t, err, "unexpected type for \"crypt\": *drivertest.MockDeployment is not driver.Crypt")
6262
})
6363

6464
t.Run("set deployment", func(t *testing.T) {
@@ -76,7 +76,7 @@ func TestSetInternalClientOptions(t *testing.T) {
7676

7777
opts := options.Client()
7878
err := SetInternalClientOptions(opts, "deployment", driver.NewCrypt(&driver.CryptOptions{}))
79-
require.EqualError(t, err, "unexpected type for deployment: *driver.crypt is not driver.Deployment")
79+
require.EqualError(t, err, "unexpected type for \"deployment\": *driver.crypt is not driver.Deployment")
8080
})
8181

8282
t.Run("set unsupported option", func(t *testing.T) {

0 commit comments

Comments
 (0)