<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:53:30 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>[SERVER-241] Can&apos;t change field data type when using $set</title>
                <link>https://jira.mongodb.org/browse/SERVER-241</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>
&lt;p&gt;The following code fails to convert the data type from a boolean to a double (calling $set). If this feature is not supported by $set, perhaps the driver should check the data type and throw an illegal argument exception if the types do not match.&lt;/p&gt;

&lt;p&gt;            if (doc.containsField(SiteDocField.HAS_SYND_FEED.key)) {&lt;br/&gt;
                final Object obj = doc.get(SiteDocField.HAS_SYND_FEED.key);&lt;br/&gt;
                if (obj != null) &lt;/p&gt;
{
                    double value = convertToDouble(obj);
                    pCol.update(new BasicDBObject(SiteDocField.ID.key, id), new BasicDBObject(&quot;$set&quot;, new BasicDBObject(SiteDocField.HAS_SYND_FEED.key, value)), false, false);
                }
&lt;p&gt; else &lt;/p&gt;
{
                    doc.removeField(SiteDocField.HAS_SYND_FEED.key);
                    pCol.save(doc);
                }
&lt;p&gt;                pDb.getDb().getLastError();&lt;br/&gt;
            }&lt;/p&gt;

&lt;p&gt;The code below successfully changes the data type (by calling save(doc)).&lt;/p&gt;

&lt;p&gt;            if (doc.containsField(SiteDocField.HAS_SYND_FEED.key)) {&lt;br/&gt;
                final Object obj = doc.get(SiteDocField.HAS_SYND_FEED.key);&lt;br/&gt;
                if (obj != null) &lt;/p&gt;
{
                      double value = convertToDouble(obj);
                     
                    // THIS IS THE CODE THAT WORKS
                    doc.put(SiteDocField.HAS_SYND_FEED.key, value);
                    pCol.save(doc);             
                }
&lt;p&gt; else &lt;/p&gt;
{
                    doc.removeField(SiteDocField.HAS_SYND_FEED.key);
                }
&lt;p&gt;                pCol.save(doc);&lt;br/&gt;
                pDb.getDb().getLastError();&lt;br/&gt;
            }&lt;/p&gt;</description>
                <environment></environment>
        <key id="10455">SERVER-241</key>
            <summary>Can&apos;t change field data type when using $set</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="5">Cannot Reproduce</resolution>
                                        <assignee username="eliot">Eliot Horowitz</assignee>
                                    <reporter username="rn@deftlabs.com">Ryan Nitz</reporter>
                        <labels>
                    </labels>
                <created>Tue, 18 Aug 2009 21:50:56 +0000</created>
                <updated>Thu, 10 Sep 2009 10:03:07 +0000</updated>
                            <resolved>Wed, 26 Aug 2009 14:13:19 +0000</resolved>
                                    <version>0.9.9</version>
                                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="10688" author="eliot" created="Thu, 10 Sep 2009 10:03:07 +0000"  >&lt;p&gt;closed b/c resolved more than 2 week ago&lt;/p&gt;</comment>
                            <comment id="10567" author="eliot" created="Wed, 26 Aug 2009 15:33:30 +0000"  >&lt;p&gt;java test that works changing bool to double with $set&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://github.com/mongodb/mongo-java-driver/commit/6785d32efefa70d9bfcda5f17ac37a3ad966c3b5&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/mongodb/mongo-java-driver/commit/6785d32efefa70d9bfcda5f17ac37a3ad966c3b5&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="10565" author="rgnitz" created="Wed, 26 Aug 2009 15:26:23 +0000"  >
&lt;p&gt;I truncated this and removed any identifiable product info.&lt;/p&gt;

&lt;p&gt;This uses a couple of custom objects and won&apos;t compile on its own.&lt;/p&gt;

&lt;p&gt;In this example... both fields were boolean (trying to convert to double). It includes the code that works and the code that did not (using $set).&lt;/p&gt;

&lt;p&gt;Let me know if you have any questions. &lt;/p&gt;</comment>
                            <comment id="10564" author="eliot" created="Wed, 26 Aug 2009 14:59:42 +0000"  >&lt;p&gt;in shell - but it shouldn&apos;t be different.&lt;br/&gt;
if you could send a java full program that reproduces - can work off of that&lt;/p&gt;</comment>
                            <comment id="10562" author="rgnitz" created="Wed, 26 Aug 2009 14:18:47 +0000"  >&lt;p&gt;You can&apos;t reproduce in the Java driver or from the shell?&lt;/p&gt;</comment>
                            <comment id="10561" author="eliot" created="Wed, 26 Aug 2009 14:13:19 +0000"  >&lt;p&gt;take a look at jstests/set2.js&lt;/p&gt;

&lt;p&gt;that seems like the same thing, but works fine.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="10028" name="ChangeDataType.java" size="4326" author="rn@deftlabs.com" created="Wed, 26 Aug 2009 15:26:23 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>6.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 26 Aug 2009 14:13:19 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        14 years, 23 weeks, 6 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></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_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>ian@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            14 years, 23 weeks, 6 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>eliot</customfieldvalue>
            <customfieldvalue>rn@deftlabs.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrpwjj:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hriv6f:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>23704</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrnvmv:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>