[GODRIVER-995] FindOne() doesn't find one with nil filter Created: 24/Apr/19 Updated: 27/Oct/23 Resolved: 25/Apr/19 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | CRUD |
| Affects Version/s: | 1.0.1, 1.0.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | David L. Parsley | Assignee: | Divjot Arora (Inactive) |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Linux, Go 1.12.4, Mongo Docker container created 2019-04-12T00:21:50.281225741Z |
||
| Description |
|
I was writing code to just grab a TODO item with no filter, but kept getting no document. I was able to easily reproduce with the Trainer example; here's a snippet: // create a value into which the result can be decoded //err = collection.FindOne(context.TODO(), filter).Decode(&result) With nil for filter: If I connect using mongo shell: I'm working around by supplying a filter that's true for all records. |
| Comments |
| Comment by Divjot Arora (Inactive) [ 25/Apr/19 ] | |
|
parsley42 The driver's operations don't support using nil where a document is expected. Like you mentioned in the description, you should use a filter that matches everything such asĀ
| |
| Comment by David L. Parsley [ 25/Apr/19 ] | |
|
To be perhaps more clear, I'm referring to reproducing this issue with your go driver tutorial: https://www.mongodb.com/blog/post/mongodb-go-driver-tutorial |