<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:49:05 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-4704] SetOnInsert not working as described</title>
                <link>https://jira.mongodb.org/browse/CSHARP-4704</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;div class=&quot;panel&quot; style=&quot;background-color: #fafbfc;border-width: 1px;&quot;&gt;&lt;div class=&quot;panelContent&quot; style=&quot;background-color: #fafbfc;&quot;&gt;
&lt;h3&gt;&lt;a name=&quot;Summary&quot;&gt;&lt;/a&gt;&lt;b&gt;Summary&lt;/b&gt;&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;The setOnInsert updatedefinition is not working as described&lt;/em&gt;&lt;br/&gt;
I wonder how to only insert a new Guid when the object was created and not updated.I thought therefore using the SetOnInsert is the right way - but it doesn&apos;t work!Every time I run the code below the object is getting a new _id:&lt;/p&gt;

&lt;p&gt;FilterDefinition&amp;lt;TestClass&amp;gt; filter = &quot;&quot;&quot;{ Path: &quot;a.b.c.d&quot; }&quot;&quot;&quot;;&lt;br/&gt;
var builder = Builders&amp;lt;TestClass&amp;gt;.Update;&lt;br/&gt;
var update = builder.SetOnInsert(&quot;_id&quot;, Guid.NewGuid()).Set(&quot;Path&quot;, &quot;a.b.c.d&quot;).Set(&quot;Name&quot;, &quot;c.d&quot;);&lt;br/&gt;
FindOneAndUpdateOptions&amp;lt;TestClass&amp;gt; options = new FindOneAndUpdateOptions&amp;lt;TestClass&amp;gt; { IsUpsert = true, ReturnDocument = MongoDB.Driver.ReturnDocument.After };&lt;/p&gt;

&lt;p&gt;var read = collNamespace.FindOneAndUpdate&amp;lt;TestClass&amp;gt;(filter, update, options);&lt;br/&gt;
How can I use FindOneAndUpdate or some other method to only set the _id once?&lt;/p&gt;


&lt;h4&gt;&lt;a name=&quot;%7B%7BFilterDefinition%3CTestClass%3Efilter%3D%22%22%22%5C%22%22%22%3B&quot;&gt;&lt;/a&gt;{{FilterDefinition&amp;lt;TestClass&amp;gt; filter = &quot;&quot;&quot;{ Path: &quot;a.b.c.d&quot; }&quot;&quot;&quot;;&lt;/h4&gt;
&lt;p&gt;var builder = Builders&amp;lt;TestClass&amp;gt;.Update;&lt;br/&gt;
var update = builder.SetOnInsert(&quot;_id&quot;, Guid.NewGuid()).Set(&quot;Path&quot;, &quot;a.b.c.d&quot;).Set(&quot;Name&quot;, &quot;c.d&quot;);&lt;br/&gt;
FindOneAndUpdateOptions&amp;lt;TestClass&amp;gt; options = new FindOneAndUpdateOptions&amp;lt;TestClass&amp;gt; { IsUpsert = true, ReturnDocument = MongoDB.Driver.ReturnDocument.After };&lt;/p&gt;

&lt;p&gt;var read = collNamespace.FindOneAndUpdate&amp;lt;TestClass&amp;gt;(filter, update, options);}}&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment></environment>
        <key id="2382070">CSHARP-4704</key>
            <summary>SetOnInsert not working as described</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="13203">Gone away</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="apatock@bfe.tv">Andreas Patock</reporter>
                        <labels>
                            <label>Bug</label>
                    </labels>
                <created>Sat, 1 Jul 2023 19:12:56 +0000</created>
                <updated>Fri, 27 Oct 2023 19:55:59 +0000</updated>
                            <resolved>Mon, 3 Jul 2023 16:08:38 +0000</resolved>
                                    <version>2.20.0</version>
                                                    <component>Operations</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="5540894" author="james.kovacs" created="Mon, 3 Jul 2023 16:08:38 +0000"  >&lt;p&gt;Thanks for letting us know.&lt;/p&gt;</comment>
                            <comment id="5539184" author="JIRAUSER1274299" created="Sun, 2 Jul 2023 11:39:48 +0000"  >&lt;p&gt;Please, close this issue. We have found the error. By misstake we use a development-mode-class which is calling &quot;DropCollection&quot; everytime. Sorry, for that.&lt;/p&gt;</comment>
                            <comment id="5538879" author="dbeng-pm-bot" created="Sat, 1 Jul 2023 19:12:59 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=apatock%40bfe.tv&quot; class=&quot;user-hover&quot; rel=&quot;apatock@bfe.tv&quot;&gt;apatock@bfe.tv&lt;/a&gt;, thank you for reporting this issue! The team will look into it and get back to you soon. &lt;/p&gt;</comment>
                    </comments>
                    <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_14266" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Documentation Changes Summary</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;1.  What would you like to communicate to the user about this feature?&lt;br/&gt;
2.  Would you like the user to see examples of the syntax and/or executable code and its output?&lt;br/&gt;
3.  Which versions of the driver/connector does this apply to?&lt;/p&gt;</customfieldvalue>

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