Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-2407

BSON Unmarshal to struct uses incorrect type alias for interface{}

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 1.10.0, 1.10.0-beta1
    • Affects Version/s: 1.9.1
    • Component/s: BSON
    • Labels:
      None

      Summary

      I'm trying to unmarshal some document received from mongo into a struct. This struct has a member that is a map[string]interface but with an alias (type metadata map[string]interface{} {}in the example below). This map can contains any data, including other map[string]interface{}{}.

      When unmarshalling the document, it's correctly parsing this member as type metadata, but it's also converting map that are included in the map as this the type metadata. I think it should be map[string]interface instead.

      Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

      1.9.1

      How to Reproduce

      https://go.dev/play/p/baefmEyupxI 

      Unmarshal as 

      {{main.data{Metadata:main.metadata{"foo":main.metadata

      {"bar":"baz"}

      }}}}

      But expected as 

      {{main.data{Metadata:main.metadata{"foo":map[string]interface {}

      {"bar":"baz"}

      }}}}
       

      Additional Background

      Please provide any additional background information that may be helpful in diagnosing the bug.

            Assignee:
            preston.vasquez@mongodb.com Preston Vasquez
            Reporter:
            thomas.chandelle@gmail.com Thomas Chandelle
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: