Skip to content

Commit 769f6da

Browse files
author
Divjot Arora
committed
Remove string key restriction for maps in LookupEncoder/LookupDecoder.
GODRIVER-713 Change-Id: Id30100a8bdb64f9cea15b42449632583a41e9f07
1 parent 3f7ddb9 commit 769f6da

File tree

2 files changed

+1
-15
lines changed

2 files changed

+1
-15
lines changed

bson/bsoncodec/registry.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,6 @@ func (r *Registry) LookupEncoder(t reflect.Type) (ValueEncoder, error) {
265265
return enc, nil
266266
}
267267

268-
if t != nil && t.Kind() == reflect.Map && t.Key().Kind() != reflect.String {
269-
r.mu.Lock()
270-
r.typeEncoders[t] = nil
271-
r.mu.Unlock()
272-
return nil, encodererr
273-
}
274-
275268
if t == nil {
276269
r.mu.Lock()
277270
r.typeEncoders[t] = nil
@@ -340,13 +333,6 @@ func (r *Registry) LookupDecoder(t reflect.Type) (ValueDecoder, error) {
340333
return dec, nil
341334
}
342335

343-
if t.Kind() == reflect.Map && t.Key().Kind() != reflect.String {
344-
r.mu.Lock()
345-
r.typeDecoders[t] = nil
346-
r.mu.Unlock()
347-
return nil, decodererr
348-
}
349-
350336
dec, found = r.kindDecoders[t.Kind()]
351337
if !found {
352338
r.mu.Lock()

bson/bsoncodec/registry_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ func TestRegistry(t *testing.T) {
253253
{
254254
"map non-string key",
255255
reflect.TypeOf(map[int]int{}),
256+
fmc,
256257
nil,
257-
ErrNoEncoder{Type: reflect.TypeOf(map[int]int{})},
258258
false,
259259
},
260260
{

0 commit comments

Comments
 (0)