Details
-
Bug
-
Resolution: Fixed
-
Major - P3
-
None
-
None
-
None
-
mongoDB go driver v1.4.0
-
Minor Change
Description
To coll.InsertMany(ctx,document, nil), InsertMany will use default options.InsertMany()
To coll.InsertOne(ctx, document, nil), InsertOne will panic because opts is [nil], and opt.BypassDocumentValidation will panic for access nil opt.
func (coll *Collection) InsertOne(ctx context.Context, document interface{}, |
opts ...*options.InsertOneOptions) (*InsertOneResult, error) {
|
|
|
imOpts := make([]*options.InsertManyOptions, len(opts))
|
for i, opt := range opts { |
imo := options.InsertMany()
|
if opt.BypassDocumentValidation != nil && *opt.BypassDocumentValidation { |
imo = imo.SetBypassDocumentValidation(*opt.BypassDocumentValidation)
|
}
|
imOpts[i] = imo
|
}
|