Details
-
Bug
-
Resolution: Gone away
-
Major - P3
-
None
-
None
-
None
-
None
-
(copied to CRM)
Description
Summary
A user is trying to use the $inc operator to increment by a small number (uint32) an int32 type. This operation makes the field be converted into int64. This snippet should return an int32 as mentioned in the comment ("If ec.MinSize or if encodeToMinSize is true for a non-uint64 value we should write val as an int32") but since useMinSize is false in his case, an int64 is returned.
Therefore the main question is, how to force useMinSize to true?
It's also worth noting that:
- EncodeToMinSize returns false in his case despite no custom codec (uintcodec)
- Therefore he uses the default encoder (defaultUIntCodec) here
- Default encoder is created here ... which does not pass in any options so EncodeToMinSize gets the Golang zero value for bool which is false.
How to Reproduce
User images are attached