<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:34:51 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-743] UpdateOne and UpdateMany should return error when update parameter is of zero length</title>
                <link>https://jira.mongodb.org/browse/GODRIVER-743</link>
                <project id="14289" key="GODRIVER">Go Driver</project>
                    <description>&lt;p&gt;The UpdateOne and UpdateMany methods do not ensure that the update parameter has at least one modifier. Update the &lt;tt&gt;ensureDollarKey&lt;/tt&gt; method to return an error if there are no modifiers provided.&lt;/p&gt;

&lt;p&gt;(original description below)&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;mongo.UpdateOne() erases all fields from a document matched by a filter when update interface is bson.D{} with zero length. That&#160;behavior is unwanted in my opinion (i&apos;ve lost some data). Mongo shell acts differently (just returns an error &apos;the update operation document must contain at least one atomic operator&apos;). I didn&apos;t check Update() and UpdateMany() but these ones may act the same as UpdateOne().&lt;/p&gt;</description>
                <environment>Ubuntu 18.04</environment>
        <key id="664781">GODRIVER-743</key>
            <summary>UpdateOne and UpdateMany should return error when update parameter is of zero length</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="divjot.arora@mongodb.com">Divjot Arora</assignee>
                                    <reporter username="ollevche">ollevche</reporter>
                        <labels>
                    </labels>
                <created>Thu, 3 Jan 2019 10:02:18 +0000</created>
                <updated>Wed, 23 Jan 2019 17:18:52 +0000</updated>
                            <resolved>Wed, 23 Jan 2019 17:18:52 +0000</resolved>
                                    <version>0.1.0</version>
                                    <fixVersion>0.3.0</fixVersion>
                                    <component>CRUD</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="2124384" author="xgen-internal-githook" created="Wed, 23 Jan 2019 17:18:34 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;divjot.arora@10gen.com&apos;, &apos;name&apos;: &apos;Divjot Arora&apos;, &apos;username&apos;: &apos;divjotarora&apos;}
&lt;p&gt;Message: Disallow empty update documents.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-743&quot; title=&quot;UpdateOne and UpdateMany should return error when update parameter is of zero length&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-743&quot;&gt;&lt;del&gt;GODRIVER-743&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Change-Id: I57ef34e7ce9368128c560fef056eff1ccede9e3b&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/commit/ecb738ac507d856715f13423d914d8fd99ac880c&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-go-driver/commit/ecb738ac507d856715f13423d914d8fd99ac880c&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2108770" author="kris.brandow" created="Tue, 8 Jan 2019 16:44:50 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jeff.yemin&quot; class=&quot;user-hover&quot; rel=&quot;jeff.yemin&quot;&gt;jeff.yemin&lt;/a&gt; the driver does support that, but there&apos;s a bug when there are no elements provided. I&apos;ll update this ticket and schedule it.&lt;/p&gt;</comment>
                            <comment id="2108428" author="jeff.yemin" created="Tue, 8 Jan 2019 13:16:16 +0000"  >&lt;p&gt;Looks like the driver does not conform to this section of the CRUD specification: &lt;a href=&quot;https://github.com/mongodb/specifications/blob/master/source/crud/crud.rst#update-vs-replace-validation&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/specifications/blob/master/source/crud/crud.rst#update-vs-replace-validation&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;The update family of operations require that the update document parameter MUST have only atomic modifiers. In practice, this means that introspection needs to happen on that document to enforce this. However, it is enough to only check the first element in the document. If it begins with a $ sign and the rest of the document&apos;s elements do not, the server will throw an error. Note that it is required that an update document have at least one atomic modifier.&lt;/p&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;The driver should be reporting this as an error and not sending the operation to the server.&lt;/p&gt;
</comment>
                            <comment id="2108269" author="ollevche" created="Tue, 8 Jan 2019 08:57:11 +0000"  >&lt;p&gt;Yes, sure. In addition to the code, i added screenshots of the matched document before and after a function call.&lt;/p&gt;

&lt;p&gt;Something like that will erase all fields (except &apos;_id&apos; field) from a matched document:&lt;/p&gt;

&lt;p&gt;&#160;&lt;br/&gt;
 &lt;tt&gt;func UpdateTest(db *mongo.Database) {&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;&#160;&#160;&#160;&#160;id, _ := primitive.ObjectIDFromHex(&quot;5c346258740d8e1c1c504455&quot;)&lt;/tt&gt;&lt;br/&gt;
 &lt;tt&gt;&#160;&#160;&#160;&#160;filter := bson.D{{&quot;_id&quot;, id&lt;/tt&gt;}}&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;&#160;&#160;&#160;&#160;db.Collection(&quot;students&quot;).UpdateOne(nil, filter, bson.D{})&lt;/tt&gt;&lt;br/&gt;
 &lt;tt&gt;}&lt;/tt&gt;&lt;br/&gt;
 &#160;&lt;br/&gt;
 Before:&lt;br/&gt;
 &lt;span class=&quot;image-wrap&quot; style=&quot;&quot;&gt;&lt;a id=&quot;205714_thumb&quot; href=&quot;https://jira.mongodb.org/secure/attachment/205714/205714_before.png&quot; title=&quot;before.png&quot; file-preview-type=&quot;image&quot; file-preview-id=&quot;205714&quot; file-preview-title=&quot;before.png&quot;&gt;&lt;img src=&quot;https://jira.mongodb.org/secure/thumbnail/205714/_thumb_205714.png&quot; style=&quot;border: 0px solid black&quot; role=&quot;presentation&quot;/&gt;&lt;/a&gt;&lt;/span&gt;&lt;br/&gt;
 After:&lt;br/&gt;
 &lt;span class=&quot;image-wrap&quot; style=&quot;&quot;&gt;&lt;a id=&quot;205713_thumb&quot; href=&quot;https://jira.mongodb.org/secure/attachment/205713/205713_after.png&quot; title=&quot;after.png&quot; file-preview-type=&quot;image&quot; file-preview-id=&quot;205713&quot; file-preview-title=&quot;after.png&quot;&gt;&lt;img src=&quot;https://jira.mongodb.org/secure/thumbnail/205713/_thumb_205713.png&quot; style=&quot;border: 0px solid black&quot; role=&quot;presentation&quot;/&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</comment>
                            <comment id="2107834" author="kris.brandow" created="Mon, 7 Jan 2019 21:00:25 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=ollevche&quot; class=&quot;user-hover&quot; rel=&quot;ollevche&quot;&gt;ollevche&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;Can you please provide a working code example of this?&lt;/p&gt;

&lt;p&gt;Thanks,&lt;/p&gt;

&lt;p&gt;Kris&lt;/p&gt;</comment>
                            <comment id="2107765" author="ollevche" created="Mon, 7 Jan 2019 20:31:20 +0000"  >&lt;p&gt;@kris.brandow&#160;it&apos;s a typo, sorry. I&apos;m using the latest one (0.1.0).&lt;/p&gt;</comment>
                            <comment id="2106135" author="kris.brandow" created="Fri, 4 Jan 2019 21:26:10 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=ollevche&quot; class=&quot;user-hover&quot; rel=&quot;ollevche&quot;&gt;ollevche&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;Can you upgrade to the latest beta (0.1.0) and try again to see if the problem persists?&lt;/p&gt;

&lt;p&gt;Thanks,&lt;/p&gt;

&lt;p&gt;Kris&lt;/p&gt;</comment>
                            <comment id="2104092" author="ollevche" created="Thu, 3 Jan 2019 10:06:37 +0000"  >&lt;p&gt;I&apos;m using&#160;0.0.10 version (not a 0.0.15).&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="205713" name="after.png" size="6320" author="ollevche" created="Tue, 8 Jan 2019 08:56:17 +0000"/>
                            <attachment id="205714" name="before.png" size="8726" author="ollevche" created="Tue, 8 Jan 2019 08:56:17 +0000"/>
                    </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_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr8bv3:</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>