<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:41:02 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>[CSHARP-1909] Using indexOf(-1) for Positional Operator does not work in bulk operations</title>
                <link>https://jira.mongodb.org/browse/CSHARP-1909</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;When attempting to use indexOf(-1) in a bulk operation update, the produced mongo query does not contain the &quot;$&quot; positional operator resulting in the query throwing an error.&lt;/p&gt;

&lt;h3&gt;&lt;a name=&quot;Example&quot;&gt;&lt;/a&gt;Example&lt;/h3&gt;

&lt;p&gt; bulk.Find(Query&amp;lt;Users&amp;gt;.Where(user =&amp;gt; user.FavoriteColors.Any(f =&amp;gt; f.Name == &quot;green&quot;)))&lt;br/&gt;
.UpdateOne(Update&amp;lt;Users&amp;gt;.Set(user =&amp;gt; user.FavoriteColors.IndexOf(-1).Name, &quot;blue&quot;);&lt;/p&gt;

&lt;p&gt;Results in {$set:&lt;/p&gt;
{&quot;user.favoriteColors.-1.name&quot;:&quot;blue&quot;}
&lt;p&gt; which throws and error.&lt;/p&gt;

&lt;h3&gt;&lt;a name=&quot;Workaround&quot;&gt;&lt;/a&gt;Workaround&lt;/h3&gt;

&lt;p&gt; bulk.Find(Query&amp;lt;Users&amp;gt;.Where(user =&amp;gt; user.FavoriteColors.Any(f =&amp;gt; f.Name == &quot;green&quot;)))&lt;br/&gt;
.UpdateOne(Update.Set(&quot;user.favoriteColors.$.name&quot;, &quot;blue&quot;);&lt;/p&gt;

&lt;p&gt;&lt;b&gt;NOTE:&lt;/b&gt; It would be nice if indexOf(-1) could be supported across ALL query builders, including legacy, current, and .net core.&lt;/p&gt;

&lt;p&gt;References: &lt;br/&gt;
&lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-531&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/CSHARP-531&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/blob/master/tests/MongoDB.Driver.Legacy.Tests/Operations/BulkWriteOperationTests.cs&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-csharp-driver/blob/master/tests/MongoDB.Driver.Legacy.Tests/Operations/BulkWriteOperationTests.cs&lt;/a&gt;&lt;/p&gt;</description>
                <environment></environment>
        <key id="352512">CSHARP-1909</key>
            <summary>Using indexOf(-1) for Positional Operator does not work in bulk operations</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="2">Won&apos;t Fix</resolution>
                                        <assignee username="dmitry.lukyanov@mongodb.com">Dmitry Lukyanov</assignee>
                                    <reporter username="exocom">Kalarrs Topham</reporter>
                        <labels>
                    </labels>
                <created>Wed, 8 Feb 2017 06:09:39 +0000</created>
                <updated>Fri, 14 Dec 2018 12:54:42 +0000</updated>
                            <resolved>Fri, 14 Dec 2018 12:54:42 +0000</resolved>
                                    <version>2.4.2</version>
                                                    <component>Linq</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="2090401" author="dmitry.lukyanov" created="Thu, 13 Dec 2018 22:07:48 +0000"  >&lt;p&gt;Dear &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=exocom&quot; class=&quot;user-hover&quot; rel=&quot;exocom&quot;&gt;exocom&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;thank you for your participation.&#160;&lt;/p&gt;

&lt;p&gt;I&apos;ve checked the ticket description as well as your pull request. I noticed that you use the builders (&lt;em&gt;Query&lt;/em&gt; and &lt;em&gt;Update&lt;/em&gt;) from the legacy driver. As we have a new, more fully-featured implementation of LINQ based on the aggregation &lt;a href=&quot;https://docs.mongodb.com/manual/aggregation/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;framework&lt;/a&gt;, we are no longer making enhancements to the legacy implementation when there are available approaches that will solve the problem. The recommended way to accomplish your target is by using the builders in the following way :&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;users.UpdateOne(&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;    Builders&amp;lt;Users&amp;gt;.Filter.Where(user =&amp;gt; user.FavoriteColors.Any(f =&amp;gt; f.Name == &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;green&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;    Builders&amp;lt;Users&amp;gt;.Update.Set(user =&amp;gt; user.FavoriteColors.ElementAt(-&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;1&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;).Name, &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;blue&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;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;
&lt;p&gt;You can also use array brackets &quot;&lt;span class=&quot;error&quot;&gt;&amp;#91;-1&amp;#93;&lt;/span&gt;&quot; instead of &lt;b&gt;ElementAt&lt;/b&gt; to reach the same result.&lt;/p&gt;

&lt;p&gt;The rendered result query from Update builder will be :&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;   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;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;$set&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;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;FavoriteColors.$.Name&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;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;blue&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;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;
&lt;p&gt;Please let me know if you still have questions.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="1496653" author="exocom" created="Fri, 10 Feb 2017 05:19:31 +0000"  >&lt;p&gt;Updated the LINQ code and added a unit test. See pull request on githhub. #269&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/pull/269&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-csharp-driver/pull/269&lt;/a&gt;&lt;/p&gt;

</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></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_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr8urz:</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>