• Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.1.1
    • Affects Version/s: 1.1.0
    • Component/s: BSON

      I've got the code below that should ignore truncation errors, but returns an error indicating it can't truncate:

              type collStats struct {
      		CollectionName string `bson:"collStats"`
      		Scale          *int64 `bson:"scale" valid:"optional,gt(0)~scale must be a number > 0"`
      	}
      
      	var cmd collStats
      	decodeContext := bsoncodec.DecodeContext{
      		Registry: bson.DefaultRegistry,
      		Truncate: true,
      	}
      	err := bson.UnmarshalWithContext(decodeContext, doc, &cmd)
      	if err != nil {
      		return nil, mongoerrors.Wrap(err, mongoerrors.CodeFailedToParse, "unable to parse the collStats command")
      	}
      

      produces the following error:

      {"collStats": "foo", "scale": 29.821 } -> IntDecodeValue can only truncate float64 to an integer type when truncation is enabled
      

            Assignee:
            alice.thum@mongodb.com Alice Thum
            Reporter:
            craig.wilson@mongodb.com Craig Wilson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: