<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:36:46 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-1616] NaN values in MongoDB</title>
                <link>https://jira.mongodb.org/browse/GODRIVER-1616</link>
                <project id="14289" key="GODRIVER">Go Driver</project>
                    <description>&lt;p&gt;2020/05/12 23:09:12 Error with mongodb://admins.find(): error decoding key osbuilddate(field OsBuildDate): IntDecodeValue can only truncate float64 to an integer type when truncation is enabled&lt;/p&gt;

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

&lt;p&gt;The trouble is that some data put into mongodb from NodeJS sources, particularly when using parseInt or parseFloat before insertion, is recorded in the db as NaN.&lt;/p&gt;

&lt;p&gt;Therefore, when the go driver tries to pull that data out, all find() requests are halted if even a single document has a value of NaN when using Find() to write to a go struct that uses an int64 field.&lt;/p&gt;

&lt;p&gt;It seems to me I could rewrite the javascript stuff and just put null or nothing in the event of having a NaN value, however NaN isn&apos;t exactly nothing.&lt;/p&gt;

&lt;p&gt;I cannot understand the reason that the go driver would fail completely in this situation.&lt;/p&gt;

&lt;p&gt;Please help.&lt;/p&gt;</description>
                <environment>linux 4.9.0, mongodb 3.6.14</environment>
        <key id="1349110">GODRIVER-1616</key>
            <summary>NaN values in MongoDB</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="13202">Works as Designed</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="andrewhodel@gmail.com">Andrew Hodel</reporter>
                        <labels>
                    </labels>
                <created>Tue, 12 May 2020 23:23:02 +0000</created>
                <updated>Fri, 27 Oct 2023 13:16:28 +0000</updated>
                            <resolved>Mon, 18 May 2020 20:14:30 +0000</resolved>
                                    <version>1.3.3</version>
                                                    <component>CRUD</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="3083537" author="JIRAUSER1251601" created="Wed, 13 May 2020 15:39:01 +0000"  >&lt;p&gt;URLs in error messages. &lt;/p&gt;

&lt;p&gt;Thank You,&lt;br/&gt;
Andrew Hodel&lt;/p&gt;
</comment>
                            <comment id="3083207" author="divjot.arora" created="Wed, 13 May 2020 14:36:03 +0000"  >&lt;p&gt;I reached out to the Node driver team. They provided this example:&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #006699; font-weight: bold; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; bson = require(&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&apos;bson&apos;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;);&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;undefined&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #006699; font-weight: bold; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; BSON = &lt;/span&gt;&lt;span style=&quot;color: #006699; font-weight: bold; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; bson();&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;undefined&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&amp;gt; x = BSON.serialize({ a: parseInt(&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&apos;false&apos;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;) })&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&amp;lt;Buffer &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;00&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;00&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;00&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;01&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;61&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;00&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;01&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;00&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;00&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;00&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;00&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;00&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; f0 7f &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;00&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&amp;gt; y = BSON.deserialize(x)&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;{ a: NaN }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;
&lt;p&gt;The buffer outputted by &lt;tt&gt;serialize&lt;/tt&gt; shows that the NaN value was stored as a BSON double (the first 4 bytes are the length and the 5th byte, 0x01, is the BSON data type for the first element, which corresponds to the Double type). You can also see this by printing that buffer as a &lt;tt&gt;bson.Raw&lt;/tt&gt; in Go, which yields&#160;{&quot;a&quot;: {&quot;$numberDouble&quot;:&quot;NaN&quot;}}.&lt;/p&gt;

&lt;p&gt;So I think Node and Go are both working as expected. NaN values are stored as double. Go reads the double as a float64, realizes that it can&apos;t be converted to an int without loss of precision, and errors. Even if we had a special-case for NaN in the code that decodes BSON double values as ints, any decision we make would be &quot;wrong&quot; because, so we feel it&apos;s best to keep the error behavior.&lt;/p&gt;</comment>
                            <comment id="3083153" author="JIRAUSER1251601" created="Wed, 13 May 2020 14:19:03 +0000"  >&lt;p&gt;Feel free to close this issue, it doesn&apos;t seem like I can and it will be a nice record for the search engines to index when other people question this activity.&lt;/p&gt;</comment>
                            <comment id="3083150" author="JIRAUSER1251601" created="Wed, 13 May 2020 14:17:41 +0000"  >&lt;p&gt;Still would be nice to know:&lt;/p&gt;

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

&lt;p&gt;And how the NodeJS driver maps Number data types to BSON_DATA structures.&lt;/p&gt;

&lt;p&gt;Something like a simple truth table for that, just like you find with common logic gates.&lt;/p&gt;

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

&lt;p&gt;Unrelated though, there just isn&apos;t room to store NaN if you efficiently store an integer.&lt;/p&gt;</comment>
                            <comment id="3082419" author="divjot.arora" created="Wed, 13 May 2020 01:09:16 +0000"  >&lt;p&gt;The Go driver can also store values into the database as NaN, but these have to be float64 values in Go for which &lt;tt&gt;math.IsNaN&lt;/tt&gt;&#160;returns true (e.g. the value returned by &lt;tt&gt;math.NaN()&lt;/tt&gt;). JavaScript&apos;s type system is very different than Go&apos;s, and the parseInt() docs say that the function returns either an integer or NaN. This isn&apos;t really a thing in Go. &lt;tt&gt;strconv.ParseInt&lt;/tt&gt; will either return an int64 or will error. It can&apos;t return NaN because doing so would require returning a float64 value.&lt;/p&gt;

&lt;p&gt;Also, this is mixing encoding and decoding. The error from the ticket description happens when decoding, and in my opinion, makes sense. If the value in the database is a IEEE 754 NaN, we can&apos;t reliably convert it to an integer without losing precision as there&apos;s no NaN integer value. Doing a naive cast like &lt;tt&gt;int64(float64FromDatabase)&lt;/tt&gt; gives math.MinInt64, which probably isn&apos;t what you want. Other languages show this behavior as well. For example, see&#160;&lt;a href=&quot;https://stackoverflow.com/questions/10366485/problems-casting-nan-floats-to-int&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://stackoverflow.com/questions/10366485/problems-casting-nan-floats-to-int&lt;/a&gt;&#160;for a C example.&lt;/p&gt;</comment>
                            <comment id="3082412" author="JIRAUSER1251601" created="Wed, 13 May 2020 01:00:58 +0000"  >&lt;p&gt;And how the NodeJS driver maps Number data types to BSON_DATA structures.&lt;/p&gt;

&lt;p&gt;Something like a simple truth table for that, just like you find with common logic gates.&lt;/p&gt;</comment>
                            <comment id="3082409" author="JIRAUSER1251601" created="Wed, 13 May 2020 00:58:39 +0000"  >&lt;p&gt;It certainly allows you to store NaN values from a number, maybe internally it is using a float as the Number type is the same for floats and integers.&lt;/p&gt;

&lt;p&gt;Regardless of JSON or BSON, BSON is being used internally.&lt;/p&gt;

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

&lt;p&gt;In order to make MongoDB JSON-first, but still high-performance and general-purpose, BSON was invented to bridge the gap: a binary representation to store data in JSON format, optimized for speed, space, and flexibility. It&#8217;s not dissimilar from other interchange formats like protocol buffers, or thrift, in terms of approach.&lt;/p&gt;

&lt;p&gt;I guess that goes to show that they left out the explanation of using BSON integers for performance reasons in most places, how silly would that become...?&lt;/p&gt;

&lt;p&gt;I suppose we really need to find out if&#160;BSON_DATA_INT supports NaN values.&lt;/p&gt;</comment>
                            <comment id="3082391" author="divjot.arora" created="Wed, 13 May 2020 00:42:24 +0000"  >&lt;p&gt;I don&apos;t know about the Node driver behavior offhand, but I can reach out to the team tomorrow to get more details about the behavior.&lt;/p&gt;

&lt;p&gt;Using &quot;@&quot; does bring up a dropdown menu of names for me so I&apos;m not sure? It&apos;s possible that it only works for internal accounts. Not a big deal, though. Once I&apos;ve commented on a ticket, I receive notifications for all new comments automatically.&lt;/p&gt;</comment>
                            <comment id="3082388" author="JIRAUSER1251601" created="Wed, 13 May 2020 00:40:59 +0000"  >&lt;p&gt;&lt;a href=&quot;https://mongodb.github.io/node-mongodb-native/api-bson-generated/bson.html&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://mongodb.github.io/node-mongodb-native/api-bson-generated/bson.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;
&lt;div class=&apos;table-wrap&apos;&gt;
&lt;table class=&apos;confluenceTable&apos;&gt;&lt;tbody&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;BSON.BSON_DATA_NUMBER&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;1&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;Number BSON Type&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
</comment>
                            <comment id="3082386" author="JIRAUSER1251601" created="Wed, 13 May 2020 00:38:59 +0000"  >&lt;p&gt;How does the NodeJS MongoDB driver manage to store values from parseInt() as NaN values in MongoDB then?&lt;/p&gt;

&lt;p&gt;Also, how did you link my name, @Divjot Arora doesn&apos;t bring up a tooltip.&lt;/p&gt;</comment>
                            <comment id="3082364" author="divjot.arora" created="Wed, 13 May 2020 00:28:23 +0000"  >&lt;p&gt;Update: I have verified that casting a NaN float64 value to int64 gives &lt;tt&gt;math.MinInt64&lt;/tt&gt;.&lt;/p&gt;</comment>
                            <comment id="3082339" author="divjot.arora" created="Wed, 13 May 2020 00:14:22 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=andrewhodel%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;andrewhodel@gmail.com&quot;&gt;andrewhodel@gmail.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;BSON does not have a data type corresponding to NaN. It does have &quot;Double&quot;, which corresponds to a Go float64. My understanding is that NaN is represented in the database as a float64 value in which the bits are laid out to represent NaN in&#160;IEEE 754 format. Given this, the driver is correctly saying that it read a float64 value.&lt;/p&gt;

&lt;p&gt;The other issue is truncation. By default, the driver will only allow float values to be decoded into integer types if doing so would not cause a loss of precision. You can opt-in to truncation even if it will cause loss of precision by using the &lt;tt&gt;truncate&lt;/tt&gt; struct tag (see second code section of&#160;&lt;a href=&quot;https://pkg.go.dev/go.mongodb.org/mongo-driver/bson?tab=doc#hdr-Structs&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://pkg.go.dev/go.mongodb.org/mongo-driver/bson?tab=doc#hdr-Structs&lt;/a&gt;):&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;type Foo struct {&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;    IntegerField &lt;/span&gt;&lt;span style=&quot;color: #006699; font-weight: bold; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; `bson:&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&quot;,truncate&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;`&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;
&lt;p&gt;NaN is a special float64 value, though, so I&apos;m not sure this is a good idea. You&apos;ll likely end up with a very large or very small integer that won&apos;t make sense. I can investigate a bit into the behavior tomorrow to give you more specific details. Either way, I&apos;d recommend sanitizing the data so you don&apos;t try to cast NaN values to integers.&lt;/p&gt;

&lt;p&gt;Hope this gives you a sense of what the driver is doing. Let me know if I can clarify anything.&lt;/p&gt;

&lt;p&gt;&amp;#8211; Divjot&lt;/p&gt;</comment>
                            <comment id="3082303" author="JIRAUSER1251601" created="Tue, 12 May 2020 23:29:35 +0000"  >&lt;p&gt;It&apos;s the same as always, thousands of hosts sending tons of data and not worth using floats.&lt;/p&gt;

&lt;p&gt;Let me know something, I&apos;ll likely just change it in JS.&lt;/p&gt;</comment>
                            <comment id="3082302" author="JIRAUSER1251601" created="Tue, 12 May 2020 23:26:51 +0000"  >&lt;p&gt;Also, the error message incorrectly describes the field as float64 when it is actually NaN.&lt;/p&gt;

&lt;p&gt;--edit well it&apos;s float64 in go, anyhow you get the idea...&#160; I guess this is really why doesn&apos;t go itself have NaN within int and int64...???&lt;/p&gt;

&lt;p&gt;I understand that go doesn&apos;t have a Number type like javascript with NaN, but&#160;&lt;a href=&quot;https://golang.org/pkg/math/#IsNaN&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://golang.org/pkg/math/#IsNaN&lt;/a&gt;&#160;exists which is probably why it is doing this.&lt;/p&gt;

&lt;p&gt;The trouble is that in JS I can have an integer value that is NaN, assuming invalid input (like a string or something) to parseInt().&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </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|hx88jz:</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>