<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:09:38 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>[CDRIVER-482] mongoc_cursor_clone() ignores fields</title>
                <link>https://jira.mongodb.org/browse/CDRIVER-482</link>
                <project id="10030" key="CDRIVER">C Driver</project>
                    <description>&lt;p&gt;I have the following function:&lt;/p&gt;

&lt;p&gt;mongoc_cursor_t *&lt;br/&gt;
get_cur(char *host, char *db, char *collection_name,&lt;br/&gt;
           mongoc_collection_t **collection_p,&lt;br/&gt;
           mongoc_client_t **client_p){&lt;br/&gt;
    mongoc_init();&lt;br/&gt;
    bson_t *query = NULL;&lt;br/&gt;
    bson_t *fields = NULL;&lt;br/&gt;
    query = bson_new ();&lt;br/&gt;
    fields = bson_new ();&lt;br/&gt;
    fields = BCON_NEW(&quot;_id&quot;, BCON_INT32 (0));&lt;/p&gt;

&lt;p&gt;    mongoc_cursor_t *cursor;&lt;br/&gt;
    *client_p = mongoc_client_new(&quot;mongodb://localhost:27017/&quot;);&lt;br/&gt;
    *collection_p = mongoc_client_get_collection (*client_p, &quot;test&quot;, &quot;test&quot;);&lt;br/&gt;
    cursor = mongoc_collection_find(*collection_p, MONGOC_QUERY_NONE, &lt;br/&gt;
                                    0, 0, 0, query, fields, NULL);&lt;br/&gt;
    return cursor;&lt;/p&gt;

&lt;p&gt;I call this function with:&lt;/p&gt;

&lt;p&gt;    cursor = get_cur(host, database, collection_name, &amp;amp;collection_p, &amp;amp;client_p);&lt;/p&gt;

&lt;p&gt;The first time I call curser next, it returns the fields without _id.&lt;br/&gt;
I then clone with with:&lt;/p&gt;

&lt;p&gt;    mongoc_cursor_t *cursor_copy;&lt;br/&gt;
    cursor_copy = mongoc_cursor_clone (cursor);&lt;/p&gt;

&lt;p&gt;And now when I do:&lt;/p&gt;

&lt;p&gt;    while (mongoc_cursor_next (cursor_copy, &amp;amp;doc)) {&lt;br/&gt;
        jsstr = bson_as_json (doc, NULL);&lt;/p&gt;

&lt;p&gt;I see the filed `_id` returned. &lt;/p&gt;

&lt;p&gt;I expected the cursor to maintain the query and field properties, e.g. &lt;br/&gt;
return documents without the field _id.&lt;/p&gt;

&lt;p&gt;Is this a bug or intended behaviour of mongoc_cursor_clone?&lt;br/&gt;
If this is not a bug, how can I specify the fields, with out calling again my own function get_cur?&lt;/p&gt;
</description>
                <environment>Debian GNU Linux, 7.0, AMD 64Bit</environment>
        <key id="173707">CDRIVER-482</key>
            <summary>mongoc_cursor_clone() ignores fields</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="-1">Unassigned</assignee>
                                    <reporter username="oz123">Oz Tiram</reporter>
                        <labels>
                            <label>driver</label>
                            <label>query</label>
                    </labels>
                <created>Wed, 10 Dec 2014 13:09:39 +0000</created>
                <updated>Wed, 19 Oct 2016 14:15:03 +0000</updated>
                            <resolved>Tue, 27 Jan 2015 18:44:47 +0000</resolved>
                                    <version> 1.0.2 </version>
                                    <fixVersion>1.1.0</fixVersion>
                                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="814582" author="xgen-internal-githook" created="Tue, 27 Jan 2015 18:44:28 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;hanumantmk&apos;, u&apos;name&apos;: u&apos;Jason Carey (hanumantmk)&apos;, u&apos;email&apos;: u&apos;jcarey@argv.me&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-482&quot; title=&quot;mongoc_cursor_clone() ignores fields&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-482&quot;&gt;&lt;del&gt;CDRIVER-482&lt;/del&gt;&lt;/a&gt; mongoc_cursor_clone() ignores fields&lt;/p&gt;

&lt;p&gt;Correctly propogate the fields parameter in copied cursors.  We copied&lt;br/&gt;
the bson, but not the flag that indicated that we&apos;d actually set&lt;br/&gt;
something.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/030eee408235a8ad8d62c654b7086a0d47c789fb&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/030eee408235a8ad8d62c654b7086a0d47c789fb&lt;/a&gt;&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|hrf7xr:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1181</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="374">Platform 00 2/20/15</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>