<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 22:02:37 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>[CXX-1430] insert_many does not return whether transaction was acknowledged</title>
                <link>https://jira.mongodb.org/browse/CXX-1430</link>
                <project id="11980" key="CXX">C++ Driver</project>
                    <description>&lt;p&gt;The official specification for insert_many is that it returns both a list of inserted ID&apos;s, but also whether the transaction was acknowledged (&lt;a href=&quot;https://docs.mongodb.com/manual/reference/method/db.collection.insertMany/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://docs.mongodb.com/manual/reference/method/db.collection.insertMany/&lt;/a&gt;). This is followed by PyMongo as well, but it seems that the C++ driver does not return this (&lt;a href=&quot;http://mongodb.github.io/mongo-cxx-driver/api/mongocxx-v3/classmongocxx_1_1result_1_1insert__many.html&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://mongodb.github.io/mongo-cxx-driver/api/mongocxx-v3/classmongocxx_1_1result_1_1insert__many.html&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Is there a reason for this?&lt;/p&gt;</description>
                <environment></environment>
        <key id="423055">CXX-1430</key>
            <summary>insert_many does not return whether transaction was acknowledged</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</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="13202">Works as Designed</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="sebastianb99">w</reporter>
                        <labels>
                    </labels>
                <created>Sat, 2 Sep 2017 11:16:57 +0000</created>
                <updated>Fri, 27 Oct 2023 13:13:44 +0000</updated>
                            <resolved>Mon, 22 Jan 2018 18:30:20 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="1781064" author="acm" created="Mon, 22 Jan 2018 18:30:07 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=sebastianb99&quot; class=&quot;user-hover&quot; rel=&quot;sebastianb99&quot;&gt;sebastianb99&lt;/a&gt; - This isn&apos;t actually a non-conformance with the specification. As you may notice in the &lt;a href=&quot;https://github.com/mongodb/specifications/blob/master/source/crud/crud.rst#results&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;results section of the driver CRUD spec&lt;/a&gt;, the &lt;tt&gt;acknowledged&lt;/tt&gt; flag is not a required field in the results type. Note what it says though: if the &lt;tt&gt;acknowledged&lt;/tt&gt; field is part of the result structure, and the field has the value &lt;tt&gt;true&lt;/tt&gt;, then the other fields of the structure have undefined values.&lt;/p&gt;

&lt;p&gt;But in C++, we have a better way to express that concept. Instead of having the &lt;tt&gt;acknowledged&lt;/tt&gt; field and invalid internal state, we can simply use &lt;tt&gt;std::optional&amp;lt;result_type&amp;gt;&lt;/tt&gt; to indicate whether the result type is present or not.&lt;/p&gt;

&lt;p&gt;All of the CRUD methods on &lt;tt&gt;mongocxx::collection&lt;/tt&gt; that return &lt;tt&gt;result::&lt;/tt&gt; types actually return &lt;tt&gt;stdx::optional&amp;lt;result::type&amp;gt;&lt;/tt&gt;. In the case of &lt;tt&gt;mongocxx::collection::insert_many&lt;/tt&gt; the &lt;a href=&quot;https://github.com/mongodb/mongo-cxx-driver/blob/master/src/mongocxx/collection.hpp#L516&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;return type is &lt;tt&gt;stdx::optional&amp;lt;result::insert_many&amp;gt;&lt;/tt&gt;&lt;/a&gt;. If the returned object is a disengaged optional, it means that no results will be returned/awaited because the operation was not performed in a manner that required it.&lt;/p&gt;

&lt;p&gt;Happy to answer any further questions on this, but I&apos;m going to close this ticket as works as designed.&lt;/p&gt;</comment>
                            <comment id="1663313" author="matt.broadstone" created="Sat, 2 Sep 2017 12:37:37 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=sebastianb99&quot; class=&quot;user-hover&quot; rel=&quot;sebastianb99&quot;&gt;sebastianb99&lt;/a&gt; You&apos;re correct that this is out of line with our CRUD spec, thanks for pointing this out! My guess is that its not provided by the underlaying C driver, but I&apos;ll look into this next week.&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_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|ht5vpr:</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>