<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:53:54 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>[JAVA-1149] $inc operator not supported with $set operation in update</title>
                <link>https://jira.mongodb.org/browse/JAVA-1149</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;I am trying to do an $inc operator from within the $set operation.&lt;br/&gt;
When I try this using the shell, it works perfectly fine:&lt;/p&gt;

&lt;p&gt;db.S_M_users.update(&lt;/p&gt;
{ &quot;sni&quot; : 4 , &quot;ki&quot; : 0 , &quot;ts&quot; :  1184437800000, 
    &quot;snun&quot; : &quot;Amazon&quot;}
&lt;p&gt;,&lt;br/&gt;
    { $set: &lt;/p&gt;
{&quot;ki&quot; : 0 , &quot;sni&quot; : 4 , &quot;ts&quot; : 1184437800000, 
        &quot;snu&quot; : &quot;UCWyLWwoPCLHHJp4NSXFV1Dw&quot; , &quot;snun&quot; : &quot;Amazon&quot; , 
        &quot;ucm&quot; : false , &quot;uiu&quot; : false}
&lt;p&gt; , $inc : { &quot;oc&quot; : 1}},true,false)&lt;/p&gt;

&lt;p&gt;But when I try to form the same query through java driver using update method it gets created like :		&lt;br/&gt;
query: &lt;/p&gt;
{ &quot;sni&quot; : 4 , &quot;ki&quot; : 0 , &quot;ts&quot; : 1184437800000 , &quot;snun&quot; : &quot;Lorem ipsum dolor&quot;}

&lt;p&gt;updateCriteria: &lt;br/&gt;
{ &quot;$set&quot; : { &quot;ki&quot; : 0 , &quot;sni&quot; : 4 , &quot;ts&quot; : 1184437800000 , &quot;snu&quot; : &quot;UCWyLWwoPCLHHJp4NSXFV1Dw&quot; , &quot;snun&quot; : &quot;Lorem ipsum dolor&quot; , &quot;ucm&quot; : false , &quot;uiu&quot; : false , &quot;$inc&quot; : &lt;/p&gt;
{ &quot;oc&quot; : 1}
&lt;p&gt;}}&lt;/p&gt;

&lt;p&gt;DB db = client.getDB(&quot;S_M_users&quot;);&lt;br/&gt;
WriteResult wr = db.getCollection(&quot;S_M_users&quot;).update(query, updateCriteria, true, false, 1);&lt;/p&gt;

&lt;p&gt;db.S_M_users.update(&lt;/p&gt;
{ &quot;sni&quot; : 4 , &quot;ki&quot; : 0 , &quot;ts&quot; : 1184437800000 , &quot;snun&quot; : &quot;Lorem ipsum dolor&quot;}
&lt;p&gt;,&lt;br/&gt;
    { &quot;$set&quot; : { &quot;ki&quot; : 0 , &quot;sni&quot; : 4 , &quot;ts&quot; : 1184437800000 , &quot;snu&quot; : &quot;UCWyLWwoPCLHHJp4NSXFV1Dw&quot; , &quot;snun&quot; : &quot;Lorem ipsum dolor&quot; , &quot;ucm&quot; : false , &quot;uiu&quot; : false , &quot;$inc&quot; : &lt;/p&gt;
{ &quot;oc&quot; : 1}
&lt;p&gt;}},true,false)&lt;/p&gt;

&lt;p&gt;And in java driver I get following exception:&lt;br/&gt;
Error while updating record: { &quot;serverUsed&quot; : &quot;CTPLSRV028:27017&quot; , &quot;err&quot; : &quot;Modified field name may not start with $&quot; , &quot;code&quot; : 15896 , &quot;n&quot; : 0 , &quot;lastOp&quot; : &lt;/p&gt;
{ &quot;$ts&quot; : 1395147947 , &quot;$inc&quot; : 1}
&lt;p&gt; , &quot;connectionId&quot; : 19680328 , &quot;ok&quot; : 1.0}&lt;/p&gt;

&lt;p&gt;There should be a way to use $inc from within a set operation using Java Driver&lt;/p&gt;</description>
                <environment></environment>
        <key id="122433">JAVA-1149</key>
            <summary>$inc operator not supported with $set operation in update</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</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="3">Duplicate</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="dj1987">Divya Jain</reporter>
                        <labels>
                            <label>driver</label>
                    </labels>
                <created>Wed, 19 Mar 2014 03:21:18 +0000</created>
                <updated>Wed, 11 Sep 2019 19:11:58 +0000</updated>
                            <resolved>Wed, 19 Mar 2014 14:36:16 +0000</resolved>
                                    <version>2.11.4</version>
                                                    <component>Write Operations</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="519153" author="gianfranco" created="Wed, 19 Mar 2014 14:36:16 +0000"  >&lt;p&gt;Closing this a duplicate&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                                        </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <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|hrwujr:</customfieldvalue>

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