<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:56:17 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-1175] findandmodify with query containing $lt causes positional ($) operator mismatch</title>
                <link>https://jira.mongodb.org/browse/SERVER-1175</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Bugfix #&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-1095&quot; title=&quot;findandmodify doesn&amp;#39;t support positional ($) operator&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-1095&quot;&gt;&lt;del&gt;SERVER-1095&lt;/del&gt;&lt;/a&gt; works only for straightforward usage.&lt;br/&gt;
We faced that adding $lt condition on integer field to the query of findandmodify operation causes $-operator mismatch.&lt;br/&gt;
Here is some code to reproduce the bug:&lt;/p&gt;

&lt;p&gt;&amp;gt; db.test.insert( {PhoneNumber:&quot;12345678&quot;, MessageParts:[&lt;/p&gt;
{PartID:&quot;a&quot;, Status:0, Timestamp:123456}
&lt;p&gt;, &lt;/p&gt;
{PartID:&quot;b&quot;, Status:0, Timestamp:123456}
&lt;p&gt;]} )          &lt;br/&gt;
&amp;gt; db.test.find()                                                                                                                               &lt;br/&gt;
{ &quot;_id&quot; : ObjectId(&quot;4c03d543299e2826314acf56&quot;), &quot;PhoneNumber&quot; : &quot;12345678&quot;, &quot;MessageParts&quot; : [&lt;br/&gt;
	&lt;/p&gt;
{
		&quot;PartID&quot; : &quot;a&quot;,
		&quot;Status&quot; : 0,
		&quot;Timestamp&quot; : 123456
	}
&lt;p&gt;,&lt;/p&gt;
	{
		&quot;PartID&quot; : &quot;b&quot;,
		&quot;Status&quot; : 0,
		&quot;Timestamp&quot; : 123456
	}
&lt;p&gt;] }&lt;/p&gt;

&lt;p&gt;// Note that we try to conditionally update the second part with ID = &quot;b&quot;. In this case item should be updated. &lt;/p&gt;

&lt;p&gt;&amp;gt; db.runCommand({findandmodify:&quot;test&quot;, query:{PhoneNumber:&quot;12345678&quot;, &quot;MessageParts.PartID&quot;:&quot;b&quot;, &quot;MessageParts.Timestamp&quot;:{ $lt:123459 }},&lt;br/&gt;
... update:{ $set: &lt;/p&gt;
{&quot;MessageParts.$.Status&quot;: 1, &quot;MessageParts.$.Timestamp&quot;:123460}
&lt;p&gt;}})  &lt;br/&gt;
{&lt;br/&gt;
	&quot;value&quot; : {&lt;br/&gt;
		&quot;_id&quot; : ObjectId(&quot;4c03d543299e2826314acf56&quot;),&lt;br/&gt;
		&quot;PhoneNumber&quot; : &quot;12345678&quot;,&lt;br/&gt;
		&quot;MessageParts&quot; : [&lt;br/&gt;
			&lt;/p&gt;
{
				&quot;PartID&quot; : &quot;a&quot;,
				&quot;Status&quot; : 0,
				&quot;Timestamp&quot; : 123456
			}
&lt;p&gt;,&lt;/p&gt;
			{
				&quot;PartID&quot; : &quot;b&quot;,
				&quot;Status&quot; : 0,
				&quot;Timestamp&quot; : 123456
			}
&lt;p&gt;		]&lt;br/&gt;
	},&lt;br/&gt;
	&quot;ok&quot; : 1&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;// Unexpected behaviour: another item is updated.&lt;/p&gt;

&lt;p&gt;&amp;gt; db.test.find()                                                                                                                          &lt;br/&gt;
{ &quot;_id&quot; : ObjectId(&quot;4c03d543299e2826314acf56&quot;), &quot;PhoneNumber&quot; : &quot;12345678&quot;, &quot;MessageParts&quot; : [&lt;br/&gt;
	&lt;/p&gt;
{
		&quot;PartID&quot; : &quot;a&quot;,
		&quot;Status&quot; : 1,
		&quot;Timestamp&quot; : 123460
	}
&lt;p&gt;,&lt;/p&gt;
	{
		&quot;PartID&quot; : &quot;b&quot;,
		&quot;Status&quot; : 0,
		&quot;Timestamp&quot; : 123456
	}
&lt;p&gt;] }&lt;/p&gt;

&lt;p&gt;// without conditions ($lt) everything works fine&lt;br/&gt;
&amp;gt; db.runCommand({findandmodify:&quot;test&quot;, query:&lt;/p&gt;
{PhoneNumber:&quot;12345678&quot;, &quot;MessageParts.PartID&quot;:&quot;b&quot;}
&lt;p&gt;,                                         &lt;br/&gt;
... update: { $set: &lt;/p&gt;
{&quot;MessageParts.$.Status&quot;:2}
&lt;p&gt; } })                                 &lt;br/&gt;
{&lt;br/&gt;
	&quot;value&quot; : {&lt;br/&gt;
		&quot;_id&quot; : ObjectId(&quot;4c03d543299e2826314acf56&quot;),&lt;br/&gt;
		&quot;PhoneNumber&quot; : &quot;12345678&quot;,&lt;br/&gt;
		&quot;MessageParts&quot; : [&lt;br/&gt;
			&lt;/p&gt;
{
				&quot;PartID&quot; : &quot;a&quot;,
				&quot;Status&quot; : 1,
				&quot;Timestamp&quot; : 123460
			}
&lt;p&gt;,&lt;/p&gt;
			{
				&quot;PartID&quot; : &quot;b&quot;,
				&quot;Status&quot; : 0,
				&quot;Timestamp&quot; : 123456
			}
&lt;p&gt;		]&lt;br/&gt;
	},&lt;br/&gt;
	&quot;ok&quot; : 1&lt;br/&gt;
}&lt;br/&gt;
&amp;gt; db.test.find()                                                                                 &lt;br/&gt;
{ &quot;_id&quot; : ObjectId(&quot;4c03d543299e2826314acf56&quot;), &quot;PhoneNumber&quot; : &quot;12345678&quot;, &quot;MessageParts&quot; : [&lt;br/&gt;
	&lt;/p&gt;
{
		&quot;PartID&quot; : &quot;a&quot;,
		&quot;Status&quot; : 1,
		&quot;Timestamp&quot; : 123460
	}
&lt;p&gt;,&lt;/p&gt;
	{
		&quot;PartID&quot; : &quot;b&quot;,
		&quot;Status&quot; : 2,
		&quot;Timestamp&quot; : 123456
	}
&lt;p&gt;] }&lt;br/&gt;
&amp;gt;   &lt;/p&gt;</description>
                <environment>Ubuntu 9.10 (on VMWare 6.5.1 under Windows 7)</environment>
        <key id="12049">SERVER-1175</key>
            <summary>findandmodify with query containing $lt causes positional ($) operator mismatch</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="mathias@mongodb.com">Mathias Stearn</assignee>
                                    <reporter username="pmm">PowerMeMobile</reporter>
                        <labels>
                    </labels>
                <created>Mon, 31 May 2010 13:10:24 +0000</created>
                <updated>Tue, 29 May 2012 14:53:28 +0000</updated>
                            <resolved>Thu, 3 Jun 2010 21:35:15 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="14588" author="redbeard0531" created="Thu, 3 Jun 2010 21:35:15 +0000"  >&lt;p&gt;You need to use $elemMatch if you want to match more than one field on a single element on the array.&lt;/p&gt;

&lt;p&gt;This will do what you want:&lt;br/&gt;
db.test.findAndModify({query:{PhoneNumber:&quot;12345678&quot;, MessageParts: {$elemMatch:{PartID:&quot;b&quot;, Timestamp:{ $lt:123459 }}}}, update: {$set: &lt;/p&gt;
{&quot;MessageParts.$.Status&quot;: 1, &quot;MessageParts.$.Timestamp&quot;:123460}
&lt;p&gt;}})&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.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 Jun 2010 21:35:15 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        13 years, 37 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>false</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>
                            13 years, 37 weeks, 6 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>mathias@mongodb.com</customfieldvalue>
            <customfieldvalue>pmm</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrijbr:</customfieldvalue>

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

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

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