Struct with bson tag _id inserts a byte array instead of objectId

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 0.0.3
    • Affects Version/s: None
    • Component/s: BSON
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      When having a struct like this:

      type TestStruct struct {
              ID   objectid.ObjectID `bson:"_id"`
      	Desc string            `bson:"desc"`
      }
      
      func Create() {
             t := TestStruct{
                    Desc: "Testing 1234"
             }
      
             .....InsertOne(context.Background(), t, nil)
      }
      

      This creates a byte[12] (Binary) value in the database instead of an objectID. When removing the `bson: "_id"` tag. It automatically creates a correct objectID. But then there is no bson mapping to the ID field in the struct.

              Assignee:
              Kristofer Brandow (Inactive)
              Reporter:
              Ad
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: