Skip to content

Commit a776a30

Browse files
committed
Make SingleResult return an error on nil registry
If the registry for SingleResult is nil, return bson.ErrNilRegistry. GODRIVER-696 Change-Id: Iea3de38c9cc2c4a348b6614f760685aadc842157
1 parent 53d0660 commit a776a30

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

mongo/command_monitoring_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func createMonitoredClient(t *testing.T, monitor *event.CommandMonitor) *Client
5555
connString: testutil.ConnString(t),
5656
readPreference: readpref.Primary(),
5757
clock: &session.ClusterClock{},
58+
registry: bson.DefaultRegistry,
5859
}
5960
}
6061

mongo/sessions_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"bytes"
1919
"strings"
2020

21+
"github.com/mongodb/mongo-go-driver/bson"
2122
"github.com/mongodb/mongo-go-driver/event"
2223
"github.com/mongodb/mongo-go-driver/internal/testutil"
2324
"github.com/mongodb/mongo-go-driver/internal/testutil/helpers"
@@ -229,6 +230,7 @@ func createSessionsMonitoredClient(t *testing.T, monitor *event.CommandMonitor)
229230
readPreference: readpref.Primary(),
230231
readConcern: readconcern.Local(),
231232
clock: clock,
233+
registry: bson.DefaultRegistry,
232234
}
233235

234236
subscription, err := c.topology.Subscribe()

mongo/single_result.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ type SingleResult struct {
3333
// will be returned. If there were no returned documents, ErrNoDocuments is
3434
// returned.
3535
func (sr *SingleResult) Decode(v interface{}) error {
36+
if sr.reg == nil {
37+
return bson.ErrNilRegistry
38+
}
3639
switch {
3740
case sr.err != nil:
3841
return sr.err

0 commit comments

Comments
 (0)