<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:40:01 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>[GODRIVER-3080] FindOneAndUpdate with options.After is not returning the updated document</title>
                <link>https://jira.mongodb.org/browse/GODRIVER-3080</link>
                <project id="14289" key="GODRIVER">Go Driver</project>
                    <description>&lt;h3&gt;&lt;a name=&quot;Detailedstepstoreproducetheproblem%3F&quot;&gt;&lt;/a&gt;Detailed steps to reproduce the problem?&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Include full traceback, if possible&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I&apos;ve taken over a project that has a method like the following:&lt;/p&gt;


&lt;p&gt;&lt;tt&gt;func (o *Object) UpdateRemovePrimaryImage() error {&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160; o.Updated = time.Now().UTC()&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160; o.PrimaryImage = nil&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;&#160; &#160; fmt.Println(&quot;before db&quot;, o.PrimaryImage)&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160; if err := db.UpdateFields(&quot;objects&quot;, o.Id, o, o); err != nil {&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160; &#160; return err&lt;/tt&gt;&lt;br/&gt;
{{&#160; &#160; }}}&lt;br/&gt;
&lt;tt&gt;&#160; &#160; fmt.Println(&quot;after db&quot;, o.PrimaryImage)&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;&#160; &#160; return nil&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;}&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;That method calls this function:&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;func UpdateFields(col, id string, fields, res interface{}) error {&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160; collection := client.Database(name).Collection(col)&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;&#160; &#160; filter := bson.D{{Key: &quot;id&quot;, Value: id&lt;/tt&gt;}}&lt;br/&gt;
&lt;tt&gt;&#160; &#160; update := bson.D{{Key: &quot;$set&quot;, Value: fields&lt;/tt&gt;}}&lt;br/&gt;
&lt;tt&gt;&#160; &#160; if err := collection.FindOneAndUpdate(&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160; &#160; context.TODO(),&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160; &#160; filter,&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160; &#160; update,&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160; &#160; options.FindOneAndUpdate().SetReturnDocument(options.After),&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160; ).Decode(res); err != nil {&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160; &#160; return err&lt;/tt&gt;&lt;br/&gt;
{{&#160; &#160; }}}&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;&#160; &#160; return nil&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;}&lt;/tt&gt;&lt;/p&gt;


&lt;p&gt;In the terminal, this is outputted:&lt;br/&gt;
&lt;tt&gt;before db &amp;lt;nil&amp;gt;&lt;/tt&gt;&lt;br/&gt;
{{after db &amp;amp;{img_Yd2nsRFnjbjKyrLvHIBPHFmwB7j6J0E18KI34 7af964cb-95d4-48ec-89c0-69987779b33f robot.jpg }}}&lt;/p&gt;


&lt;p&gt;This isn&apos;t how I would do things, but I&apos;m surprised that the original document is being returned. Is this expected behavior?&lt;/p&gt;
&lt;h3&gt;&lt;a name=&quot;Definitionofdone%3Awhatmustbedonetoconsiderthetaskcomplete%3F&quot;&gt;&lt;/a&gt;Definition of done: what must be done to consider the task complete?&lt;/h3&gt;
&lt;h3&gt;&lt;a name=&quot;TheexactGoversionused%2Cwithpatchlevel%3A&quot;&gt;&lt;/a&gt;The exact Go version used, with patch level:&lt;/h3&gt;

&lt;p&gt;&lt;tt&gt;$ go version&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;go version go1.21.5 linux/amd64&lt;/tt&gt;&lt;/p&gt;
&lt;h3&gt;&lt;a name=&quot;TheexactversionoftheGodriverused%3A&quot;&gt;&lt;/a&gt;The exact version of the Go driver used:&lt;/h3&gt;

&lt;p&gt;&lt;tt&gt;$ go list -m go.mongodb.org/mongo-driver&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;go.mongodb.org/mongo-driver v1.13.1&lt;/tt&gt;&lt;/p&gt;
&lt;h3&gt;&lt;a name=&quot;DescribehowMongoDBissetup.LocalvsHosted%2Cversion%2Ctopology%2Cloadbalanced%2Cetc.&quot;&gt;&lt;/a&gt;Describe how MongoDB is set up. Local vs Hosted, version, topology, load balanced, etc.&lt;/h3&gt;

&lt;p&gt;M10 hosted on Atlas, 7.0.4.&lt;/p&gt;
&lt;h3&gt;&lt;a name=&quot;Theoperatingsystemandversion%28e.g.Windows7%2COSX10.8%2C...%29&quot;&gt;&lt;/a&gt;The operating system and version (e.g. Windows 7, OSX 10.8, ...)&lt;/h3&gt;

&lt;p&gt;Linux 6.6.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 14 Dec 2023 03:45:42 +0000 x86_64 GNU/Linux&lt;/p&gt;
&lt;h3&gt;&lt;a name=&quot;SecurityVulnerabilities&quot;&gt;&lt;/a&gt;&lt;b&gt;Security Vulnerabilities&lt;/b&gt;&lt;/h3&gt;

&lt;p&gt;If you&#8217;ve identified a security vulnerability in a driver or any other MongoDB project, please report it according to the instructions &lt;a href=&quot;https://www.mongodb.com/docs/manual/tutorial/create-a-vulnerability-report/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;&lt;/p&gt;</description>
                <environment></environment>
        <key id="2533787">GODRIVER-3080</key>
            <summary>FindOneAndUpdate with options.After is not returning the updated document</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="11263" iconUrl="https://jira.mongodb.org/images/icons/statuses/generic.png" description="">Scheduled</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="matt.dale@mongodb.com">Matt Dale</assignee>
                                    <reporter username="dwrz@museumexchange.com">David Wen Riccardi-Zhu</reporter>
                        <labels>
                    </labels>
                <created>Thu, 28 Dec 2023 21:34:45 +0000</created>
                <updated>Thu, 18 Jan 2024 21:54:32 +0000</updated>
                                            <version>1.13.1</version>
                                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="5974358" author="dbeng-pm-bot" created="Thu, 28 Dec 2023 21:34:48 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=dwrz%40museumexchange.com&quot; class=&quot;user-hover&quot; rel=&quot;dwrz@museumexchange.com&quot;&gt;dwrz@museumexchange.com&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_23812" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Assigned Team</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="26446"><![CDATA[Go Drivers]]></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|i2nwis:</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>