-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Environment:mongoDB go driver v1.4.0
-
Minor Change
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 }