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

omitempty doesnt work on primitive.Decimal128

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.4.4
    • Affects Version/s: 1.4.2
    • Component/s: BSON
    • Labels:
      None

      type Something struct {
      	Field primitive.Decimal128 `bson:"field,omitempty"`
      }
      
      func main() {
              // Connect to mongo instance
              // ... 
      
      	something := Something{}
      	collection := client.Database("invoice").Collection("something")
      	_, err = collection.InsertOne(context.Background(), something)
      	if err != nil {
      		log.Fatal(err)
      	}
      
      }
      
      

      After running the above, a record is created with the primitive.Decimal128 field while it should be omitted.

      {
          "field": {
              "$numberDecimal": "0E-6176"
          }
      }
      

            Assignee:
            isabella.siu@mongodb.com Isabella Siu (Inactive)
            Reporter:
            graffcameron@gmail.com Cam Graff
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: