diff --git a/codec_record.go b/codec_record.go index 7cfdbef..4a01b12 100644 --- a/codec_record.go +++ b/codec_record.go @@ -275,7 +275,7 @@ func decoderOfRecord(d *decoderContext, schema Schema, typ reflect2.Type) ValDec fields[i] = recordMapDecoderField{ name: field.Name(), - decoder: newEfaceDecoder(d, field.Type()), + decoder: decoderOfType(d, field.Type(), mapType.Elem()), } } diff --git a/decoder_record_test.go b/decoder_record_test.go index 0d1d23f..69faf7c 100644 --- a/decoder_record_test.go +++ b/decoder_record_test.go @@ -236,13 +236,14 @@ func TestDecoder_RecordEmbeddedIntStruct(t *testing.T) { func TestDecoder_RecordMap(t *testing.T) { defer ConfigTeardown() - data := []byte{0x36, 0x06, 0x66, 0x6f, 0x6f} + data := []byte{0x36, 0x06, 0x66, 0x6f, 0x6f, 0x02, 0x06, 0x66, 0x6f, 0x6f} schema := `{ "type": "record", "name": "test", "fields" : [ {"name": "a", "type": "long"}, - {"name": "b", "type": "string"} + {"name": "b", "type": "string"}, + {"name": "c", "type": ["null","string"]} ] }` dec, err := avro.NewDecoder(schema, bytes.NewReader(data)) @@ -252,7 +253,7 @@ func TestDecoder_RecordMap(t *testing.T) { err = dec.Decode(&got) require.NoError(t, err) - assert.Equal(t, map[string]any{"a": int64(27), "b": "foo"}, got) + assert.Equal(t, map[string]any{"a": int64(27), "b": "foo", "c": "foo"}, got) } func TestDecoder_RecordMapInvalidKey(t *testing.T) {