BSON Marshaller ignores fields of an embedded structure of the schema

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 1.0.0
    • Component/s: BSON
    • None
    • Environment:
      Ubuntu 18.04 amd64
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I declare schemas. For example:

      Unable to find source-code formatter for language: golang. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      type Embedded struct {
        Name string `bson:"name"`
      }
      
      type Main struct {
        Embedded
        OtherField int64 `bson:"otherField"`
      }
      

      When I try to load an instance of Main structure from the database, e.g.:

      Unable to find source-code formatter for language: golang. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      cursor, err := client.Database("my").Collection("myColl").Find(context.TODO(), bsonD{})
      
      if err != nil {
       return err
      }
      
      for cursor.Next(context.TODO()) {
        var m Main
        if err := cursor.Decode(&m); err != nil {
          return err
        }
      
        fmt.Printf("name=\"%s\"\n", m.Name) // outputs `name=""`
      }
      

            Assignee:
            Kristofer Brandow (Inactive)
            Reporter:
            Alexey Nosov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: