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

omitempty doesnt work on primitive.Decimal128

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 1.4.2
    • Fix Version/s: 1.4.4
    • Component/s: BSON
    • Security Level: Public
    • Labels:
      None

      Description

      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"
          }
      }
      

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: