<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:53:56 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-390] upsert with x.y query misinterpreted by server</title>
                <link>https://jira.mongodb.org/browse/SERVER-390</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Looks like one of the upsert syntaxes is misinterpreted on the server&lt;br/&gt;
(seems to be a server bug rather than a shell bug, I get the same&lt;br/&gt;
behavior in the Java driver). Before I enter this in JIRA, since I&apos;m&lt;br/&gt;
not sure of the terminology, maybe someone could let me know if it&apos;s a&lt;br/&gt;
known bug. My comments after the //&lt;/p&gt;

&lt;p&gt;&amp;gt; db.testcoll.drop();&lt;/p&gt;

{&quot;nIndexesWas&quot; : 1 , &quot;msg&quot; : &quot;all indexes deleted for collection&quot; ,
&quot;ns&quot; : &quot;mfs.testcoll&quot; , &quot;ok&quot; : 1}
&lt;p&gt;&amp;gt; db.testcoll.update({foo: {bar: 123}}, {&quot;$inc&quot;: {&quot;baz&quot;: 1}}, &lt;/p&gt;
{upsert: true}
&lt;p&gt;)&lt;br/&gt;
&amp;gt; db.testcoll.find()&lt;/p&gt;

&lt;p&gt;{&quot;_id&quot; :  ObjectId( &quot;4ae725fd4666000000000f21&quot;)  , &quot;foo&quot; : &lt;/p&gt;
{&quot;bar&quot; :
123}
&lt;p&gt; , &quot;baz&quot; : 1}&lt;br/&gt;
// we upsert an object with a foo field matching exactly the value&lt;/p&gt;
{bar: 123}
&lt;p&gt; and containing no other fields. It doesn&apos;t exist so we&lt;br/&gt;
create it and increment &quot;baz&quot;.&lt;/p&gt;

&lt;p&gt;&amp;gt; db.testcoll.update(&lt;/p&gt;
{&quot;foo.bar&quot;: 123}
&lt;p&gt;, {&quot;$inc&quot;: {&quot;baz&quot;: 1}}, &lt;/p&gt;
{upsert: true}
&lt;p&gt;)&lt;br/&gt;
&amp;gt; db.testcoll.find()&lt;/p&gt;

&lt;p&gt;{&quot;_id&quot; :  ObjectId( &quot;4ae725fd4666000000000f21&quot;)  , &quot;foo&quot; : &lt;/p&gt;
{&quot;bar&quot; :
123}
&lt;p&gt; , &quot;baz&quot; : 2}&lt;br/&gt;
// we upsert an object with a foo field containing a bar field whose&lt;br/&gt;
value is 123. It exists already so &quot;baz&quot; is incremented.&lt;/p&gt;

&lt;p&gt;&amp;gt; db.testcoll.drop()&lt;/p&gt;

{&quot;nIndexesWas&quot; : 1 , &quot;msg&quot; : &quot;all indexes deleted for collection&quot; ,
&quot;ns&quot; : &quot;mfs.testcoll&quot; , &quot;ok&quot; : 1}
&lt;p&gt;&amp;gt; db.testcoll.update(&lt;/p&gt;
{&quot;foo.bar&quot;: 123}
&lt;p&gt;, {&quot;$inc&quot;: {&quot;baz&quot;: 1}}, &lt;/p&gt;
{upsert: true}
&lt;p&gt;)&lt;br/&gt;
&amp;gt; db.testcoll.find()&lt;/p&gt;

{&quot;_id&quot; :  ObjectId( &quot;4ae726234666000000000f22&quot;)  , &quot;foo.bar&quot; : 123 ,
&quot;baz&quot; : 1}
&lt;p&gt;// Again we upsert an object with a foo field containing a bar field&lt;br/&gt;
whose value is 123. It doesn&apos;t exist already. But this time the server&lt;br/&gt;
seems to misinterpret the query &lt;/p&gt;
{&quot;foo.bar&quot; : 123}
&lt;p&gt; and creates a new&lt;br/&gt;
record with the field &quot;foo.bar&quot;, rather than a new record with the&lt;br/&gt;
field &quot;foo&quot; containing a subfield &quot;bar&quot;.&lt;/p&gt;</description>
                <environment></environment>
        <key id="10807">SERVER-390</key>
            <summary>upsert with x.y query misinterpreted by server</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="9">Done</resolution>
                                        <assignee username="eliot">Eliot Horowitz</assignee>
                                    <reporter username="jmsachs">Jason Sachs</reporter>
                        <labels>
                    </labels>
                <created>Tue, 27 Oct 2009 13:31:14 +0000</created>
                <updated>Tue, 12 Jul 2016 00:29:19 +0000</updated>
                            <resolved>Sat, 16 Jan 2010 10:25:55 +0000</resolved>
                                    <version>1.0.0</version>
                                    <fixVersion>1.3.1</fixVersion>
                                    <component>Write Ops</component>
                                        <votes>1</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="11805" author="auto" created="Sat, 16 Jan 2010 10:25:58 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Eliot Horowitz&apos;, &apos;email&apos;: &apos;eliot@10gen.com&apos;}
&lt;p&gt;Message: fix upset with x.y query and $mod &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-390&quot; title=&quot;upsert with x.y query misinterpreted by server&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-390&quot;&gt;&lt;del&gt;SERVER-390&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://github.com/mongodb/mongo/commit/d61342572459e7942871b427e373a686a04b55f7&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/mongodb/mongo/commit/d61342572459e7942871b427e373a686a04b55f7&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="11764" author="jstephens" created="Wed, 13 Jan 2010 16:48:22 +0000"  >&lt;p&gt;I get the same thing from the Perl driver on 1.2.1.  See PERL-48.  Didn&apos;t see this bug until now.&lt;/p&gt;</comment>
                            <comment id="11401" author="eliot" created="Wed, 16 Dec 2009 21:51:52 +0000"  >&lt;p&gt;split out case for $ queries&lt;/p&gt;</comment>
                            <comment id="11272" author="ibwhite" created="Thu, 3 Dec 2009 22:37:11 +0000"  >&lt;p&gt;Here&apos;s another, somewhat related, problem with upserts &amp;#8211; feel free to split but you might be able to kill these two birds with one stone:&lt;/p&gt;


&lt;p&gt;&amp;gt; db.test.drop();    &lt;br/&gt;
true&lt;br/&gt;
&amp;gt; db.test.update( { name: &apos;ian&apos;, fruits: &lt;/p&gt;
{ $ne: &apos;apple&apos; }
&lt;p&gt; }, { $push: &lt;/p&gt;
{ fruits: &apos;apple&apos; }
&lt;p&gt; }, &lt;/p&gt;
{ upsert: true }
&lt;p&gt; );&lt;br/&gt;
Cannot apply $push/$pushAll modifier to non-array&lt;/p&gt;

&lt;p&gt;(I&apos;m using the $ne conditional as a workaround for the lack of a $pushUnique / $pushAllUnique)&lt;/p&gt;

&lt;p&gt;Anyway, the problem is that the first parameter is doing double duty as both criteria and the object to insert, so mongo thinks I mean to insert the literal subobject &lt;/p&gt;
{ $ne: &apos;apple&apos; }
&lt;p&gt;, and then run a $push on it, which isn&apos;t allowed. Jason is encountering a similar problem: the dot-notation he&apos;s using for criteria is not suitable for the inserted object.&lt;/p&gt;

&lt;p&gt;I&apos;m starting to think it might be best if upsert was different from update and was something like&lt;/p&gt;

&lt;p&gt;upsert(criteria, insert, update)&lt;/p&gt;


&lt;p&gt;This would fix Jason&apos;s problem, because he&apos;d do:&lt;/p&gt;

&lt;p&gt;db.testcol.upsert( &lt;/p&gt;
{ &apos;foo.bar&apos;: 123 }
&lt;p&gt;, { foo: &lt;/p&gt;
{ bar: 123 }
&lt;p&gt;, baz: 1 }, { $inc: &lt;/p&gt;
{ baz: 1 }
&lt;p&gt; } );&lt;/p&gt;


&lt;p&gt;And it would fix my problem, because I&apos;d do (at least until we get $pushUnique):&lt;/p&gt;

&lt;p&gt;db.test.upsert( { name: &apos;ian&apos;, fruits: &lt;/p&gt;
{ $ne: &apos;apple&apos; }
&lt;p&gt; }, &lt;/p&gt;
{ name: &apos;ian&apos;, fruits: [&apos;apple&apos;] }
&lt;p&gt;, { $push: &lt;/p&gt;
{ fruits: &apos;apple&apos; }
&lt;p&gt; } )&lt;/p&gt;


&lt;p&gt;And it would resolve #453 as well.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                        <issuelink>
            <issuekey id="10937">SERVER-453</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="11015">SERVER-492</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>4.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 3 Dec 2009 22:37:11 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        14 years, 5 weeks, 4 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>ramon.fernandez@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            14 years, 5 weeks, 4 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Old_Backport</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10000"><![CDATA[No]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>auto</customfieldvalue>
            <customfieldvalue>eliot</customfieldvalue>
            <customfieldvalue>ibwhite</customfieldvalue>
            <customfieldvalue>jmsachs</customfieldvalue>
            <customfieldvalue>jstephens</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrpv13:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>22202</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|hszyun:</customfieldvalue>

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