<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:38:38 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[GODRIVER-2451] int32 is converted to int64 after incrementing</title>
                <link>https://jira.mongodb.org/browse/GODRIVER-2451</link>
                <project id="14289" key="GODRIVER">Go Driver</project>
                    <description>&lt;h4&gt;&lt;a name=&quot;Summary&quot;&gt;&lt;/a&gt;Summary&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;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. &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-2451&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;This snippet&lt;/a&gt; should return an int32 as mentioned in the comment (&quot;If ec.MinSize or if encodeToMinSize is true for a non-uint64 value we should write val as an int32&quot;) but since useMinSize is false in his case, an int64 is returned.&lt;/em&gt;&#160;&lt;/p&gt;

&lt;p&gt;Therefore the main question is, how to force useMinSize to true?&lt;/p&gt;

&lt;p&gt;It&apos;s also worth noting that:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;EncodeToMinSize returns false in his case despite no custom codec (uintcodec)&lt;/li&gt;
	&lt;li&gt;Therefore he uses the default encoder (defaultUIntCodec) &lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/blob/v1.9.1/bson/bsoncodec/default_value_encoders.go#L100&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;Default encoder is created &lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/blob/v1.9.1/bson/bsoncodec/uint_codec.go#L25&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt; ... which does not pass in any options so EncodeToMinSize gets the Golang zero value for bool which is false.&lt;/li&gt;
&lt;/ul&gt;


&lt;h4&gt;&lt;a name=&quot;HowtoReproduce&quot;&gt;&lt;/a&gt;How to Reproduce&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;User images are attached&lt;/em&gt;&lt;/p&gt;</description>
                <environment></environment>
        <key id="2062271">GODRIVER-2451</key>
            <summary>int32 is converted to int64 after incrementing</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="13203">Gone away</resolution>
                                        <assignee username="benji.rewis@mongodb.com">Benji Rewis</assignee>
                                    <reporter username="pierre.depretz@mongodb.com">Pierre Depretz</reporter>
                        <labels>
                    </labels>
                <created>Sun, 5 Jun 2022 23:51:03 +0000</created>
                <updated>Fri, 27 Oct 2023 20:01:12 +0000</updated>
                            <resolved>Thu, 30 Jun 2022 12:00:58 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>5</watches>
                                                                                                                <comments>
                            <comment id="4650126" author="dbeng-pm-bot" created="Thu, 30 Jun 2022 12:00:59 +0000"  >&lt;p&gt;There hasn&apos;t been any recent activity on this ticket, so we&apos;re resolving it. Thanks for reaching out! Please feel free to comment on this if you&apos;re able to provide more information.&lt;/p&gt;</comment>
                            <comment id="4618791" author="benji.rewis" created="Wed, 15 Jun 2022 19:26:43 +0000"  >&lt;p&gt;Hello &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=pierre.depretz%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;pierre.depretz@mongodb.com&quot;&gt;pierre.depretz@mongodb.com&lt;/a&gt;! Thanks for your bug report, and apologies for the late response. The Go driver team was at MongoDB world last week, and I just got a chance to take a deeper look at this.&lt;/p&gt;

&lt;p&gt;Firstly, I was incorrect in my &lt;a href=&quot;https://mongodb.slack.com/archives/C7WJZNUTA/p1654247893497509?thread_ts=1654213793.819759&amp;amp;cid=C7WJZNUTA&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;earlier statements&lt;/a&gt; on Slack. The default BSON registry in the Go driver registers a &lt;tt&gt;UIntCodec&lt;/tt&gt; with &lt;tt&gt;EncodeToMinSize&lt;/tt&gt; set to &lt;b&gt;false&lt;/b&gt; &lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/blob/d02ee16477b0cfdbe6d47595a552f1d1f8696f32/bson/bsoncodec/uint_codec.go#L25&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;by default&lt;/a&gt;. So, by default, any &lt;tt&gt;uint32&lt;/tt&gt; encoded by our BSON library will be written as an Int64. I&apos;m not sure I agree with this behavior (it seems odd to me that we wouldn&apos;t default to using the minimum size), so I&apos;ve filed &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-2460&quot; title=&quot;Consider always encoding $inc value as minimum integer size&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-2460&quot;&gt;GODRIVER-2460&lt;/a&gt;. Unfortunately, we cannot change the default behavior without breaking current users&apos; code, so that potential change will have to wait until version 2.0 of the driver.&lt;/p&gt;

&lt;p&gt;I believe what&apos;s happening in your example is that the &lt;tt&gt;uint32&lt;/tt&gt; value you&apos;re passing to &lt;tt&gt;$inc&lt;/tt&gt; is being encoded as an &lt;tt&gt;Int64&lt;/tt&gt; in BSON. When the existing &lt;tt&gt;age&lt;/tt&gt; field is incremented by an &lt;tt&gt;Int64&lt;/tt&gt;, its type switches to &lt;tt&gt;Int64&lt;/tt&gt; from &lt;tt&gt;Int32&lt;/tt&gt;. I would suggest specifying a custom &lt;tt&gt;Registry&lt;/tt&gt;&#160;with a custom &lt;tt&gt;UIntCodec&lt;/tt&gt; in your &lt;tt&gt;Client&lt;/tt&gt; creation. Here&apos;s an example of what that might&#160;look like:&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;nobr&quot;&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/attachment/385084/385084_increment.go&quot; title=&quot;increment.go attached to GODRIVER-2451&quot;&gt;increment.go&lt;sup&gt;&lt;img class=&quot;rendericon&quot; src=&quot;https://jira.mongodb.org/images/icons/link_attachment_7.gif&quot; height=&quot;7&quot; width=&quot;7&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/sup&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Let me know if that workaround is helpful, and if not, I may have alternative suggestions.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="383109" name="image+(3).png" size="17190" author="pierre.depretz@mongodb.com" created="Sun, 5 Jun 2022 23:33:52 +0000"/>
                            <attachment id="383108" name="image+(4).png" size="17830" author="pierre.depretz@mongodb.com" created="Sun, 5 Jun 2022 23:33:52 +0000"/>
                            <attachment id="383107" name="image+(5).png" size="100593" author="pierre.depretz@mongodb.com" created="Sun, 5 Jun 2022 23:33:53 +0000"/>
                            <attachment id="383106" name="image+(6).png" size="41183" author="pierre.depretz@mongodb.com" created="Sun, 5 Jun 2022 23:33:52 +0000"/>
                            <attachment id="383105" name="image+(7).png" size="91353" author="pierre.depretz@mongodb.com" created="Sun, 5 Jun 2022 23:33:53 +0000"/>
                            <attachment id="383104" name="image+(8).png" size="123987" author="pierre.depretz@mongodb.com" created="Sun, 5 Jun 2022 23:33:53 +0000"/>
                            <attachment id="385084" name="increment.go" size="1653" author="benji.rewis@mongodb.com" created="Wed, 15 Jun 2022 19:27:00 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                    <customfield id="customfield_13552" key="com.go2group.jira.plugin.crm:crm_generic_field">
                        <customfieldname>Case</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[[5006R00001ltQIJQA2]]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i0gdxk:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>