[GODRIVER-909] Problem if filter in Distinct is nil Created: 28/Mar/19  Updated: 02/Apr/19  Resolved: 02/Apr/19

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: 1.0.0
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Robert Ressl Assignee: Kristofer Brandow (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

There is a problem in the Distinct function. If the filter is nil, the distinct will not be executed:

collection.Distinct(context.Background(), "foo.bar", nil)

As a workaround I have used a blank search request:

collection.Distinct(context.Background(), "foo.bar", bson.D{})



 Comments   
Comment by Robert Ressl [ 29/Mar/19 ]

Hi kris.brandow,
 

Okay, thanks for the information. In the not stable driver, it was possible with nil.

Yes, I receive an error: 'document is nil'
 

Thanks,
Robert

Comment by Kristofer Brandow (Inactive) [ 28/Mar/19 ]

Hi r.ressl,

The mongo package's documentation states: "All Client, Collection, and Database methods that take parameters of type interface{} will return ErrNilDocument if nil is passed in for an interface{}", therefore nil is not a valid parameter for Distinct. Did you receive ErrNilDocument from the call to Distinct or another error?

Comment by Robert Ressl [ 28/Mar/19 ]

go version go1.12.1 darwin/amd64

Generated at Thu Feb 08 08:35:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.