omitempty doesnt work on primitive.Decimal128

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 1.4.4
    • Affects Version/s: 1.4.2
    • Component/s: BSON
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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 (Inactive)
            Reporter:
            Cam Graff
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: