Skip to content

Commit 3069e04

Browse files
jiangz222kevinAlbs
authored andcommitted
GODRIVER-1793 Avoid crash when opts is [nil] in InsertOne
1 parent 3ce1141 commit 3069e04

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mongo/collection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ func (coll *Collection) InsertOne(ctx context.Context, document interface{},
329329
imOpts := make([]*options.InsertManyOptions, len(opts))
330330
for i, opt := range opts {
331331
imo := options.InsertMany()
332-
if opt.BypassDocumentValidation != nil && *opt.BypassDocumentValidation {
332+
if opt != nil && opt.BypassDocumentValidation != nil && *opt.BypassDocumentValidation {
333333
imo = imo.SetBypassDocumentValidation(*opt.BypassDocumentValidation)
334334
}
335335
imOpts[i] = imo

0 commit comments

Comments
 (0)