<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:38:09 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-2244] Golang driver has a rather poor support for Decimal128</title>
                <link>https://jira.mongodb.org/browse/GODRIVER-2244</link>
                <project id="14289" key="GODRIVER">Go Driver</project>
                    <description>&lt;p&gt;Currently the mogodb driver has support for Decimal128 bson type. However, this type is rather useless as no arithmetic operations are supported on it (only conversions from strings, etc.).&lt;/p&gt;

&lt;p&gt;There is a decimal package for go with a rich API at&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://pkg.go.dev/github.com/shopspring/decimal&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://pkg.go.dev/github.com/shopspring/decimal&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;it would be nice to make compatible with this type or provide a similar API.&lt;/p&gt;

&lt;p&gt;Note that a decimal type is very useful for instance in financial applications that require exact representation of the values.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</description>
                <environment></environment>
        <key id="1934252">GODRIVER-2244</key>
            <summary>Golang driver has a rather poor support for Decimal128</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="10300" iconUrl="https://jira.mongodb.org/images/icons/priorities/medium.svg">Unknown</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="pdenapo@gmail.com">Pablo De Napoli</reporter>
                        <labels>
                    </labels>
                <created>Sat, 27 Nov 2021 16:03:14 +0000</created>
                <updated>Fri, 27 Oct 2023 20:01:14 +0000</updated>
                            <resolved>Wed, 15 Dec 2021 12:00:32 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="4249290" author="dbeng-pm-bot" created="Wed, 15 Dec 2021 12:00:33 +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="4221187" author="benji.rewis" created="Tue, 30 Nov 2021 16:19:29 +0000"  >&lt;p&gt;Hello &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=pdenapo%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;pdenapo@gmail.com&quot;&gt;pdenapo@gmail.com&lt;/a&gt;, and thanks for your improvement suggestion!&lt;/p&gt;

&lt;p&gt;The lack of artithmetic operations on our &lt;tt&gt;primitive.Decimal128&lt;/tt&gt; type has come up a few times, now. I&#8217;ve linked this ticket to a recent request, &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-1922&quot; title=&quot;Arithmetic functions with Decimal128&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-1922&quot;&gt;&lt;del&gt;GODRIVER-1922&lt;/del&gt;&lt;/a&gt;, that may have some useful context.&lt;/p&gt;

&lt;p&gt;To paraphrase from some comments there, we cannot implement arithmetic functions for the &lt;tt&gt;Decimal128&lt;/tt&gt; type. Our specifications for the &lt;tt&gt;Decimal128&lt;/tt&gt; type (to which all drivers must adhere) &lt;a href=&quot;https://github.com/mongodb/specifications/blob/master/source/bson-decimal128/decimal128.rst#operator-overloading-and-math-on-decimal128-value-objects&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;explicitly forbid&lt;/a&gt; implementing math operations on the type. No official MongoDB driver has arithmetic methods for their BSON Decimal128 types. Implementing, maintaining, and guaranteeing correctness of IEEE decimal support is far from trivial, and a mistake could be disastrous given the importance of arbitrary-precision-decimal-floating-point-number arithmetic (especially in, as you mentioned, financial applications).&lt;/p&gt;

&lt;p&gt;We do understand that converting between &lt;tt&gt;primitive.Decimal128&lt;/tt&gt; and other popular decimal libraries (like &lt;tt&gt;shopspring&lt;/tt&gt;) can add undesired overhead to perform arithmetic functions. The main pain point there seems to be having to check errors for conversions to and from &lt;tt&gt;primitive.Decimal128&lt;/tt&gt;.&lt;/p&gt;

&lt;p&gt;We can suggest an alternative of registering a custom BSON codec for your preferred decimal type that converts to and from &lt;tt&gt;primitive.Decimal128&lt;/tt&gt;. Doing so would mean that conversion errors only appear in Marshaling and Unmarshaling, and you could insert/query with your preferred decimal type rather than &lt;tt&gt;primitive.Decimal128&lt;/tt&gt;. That way, from your application&#8217;s point of view, you&#8217;d never even touch &lt;tt&gt;primitive.Decimal128&lt;/tt&gt;. Decimal values would only be stored in your collections as &lt;tt&gt;primitive.Decimal128&lt;/tt&gt;. I&#8217;ve attached an example of registering a custom codec for &lt;tt&gt;shopspring.Decimal&lt;/tt&gt;.&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;nobr&quot;&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/attachment/348452/348452_shopspringcodec.go&quot; title=&quot;shopspringcodec.go attached to GODRIVER-2244&quot;&gt;shopspringcodec.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;Does that solution seem like it might help in your case? If not, feel free to elaborate on your use-case, and I may be able to suggest other paths forward.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="1649748">GODRIVER-1922</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="348452" name="shopspringcodec.go" size="4135" author="benji.rewis@mongodb.com" created="Tue, 30 Nov 2021 16:18:04 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <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|hzv5jj:</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>