XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 1.1.0
    • Fix Version/s: 1.1.1
    • Component/s: BSON
    • Labels:

      Description

      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
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: