<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:42:22 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-2374] Aggregate Option Comment gives an error when doing an AggregateAsync</title>
                <link>https://jira.mongodb.org/browse/CSHARP-2374</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;Hello&lt;/p&gt;

&lt;p&gt;When I do this:&lt;/p&gt;

&lt;p&gt;var options = new AggregateOptions&lt;br/&gt;
 &lt;/p&gt;
{
AllowDiskUse = true,
 Comment = &quot;TESTE&quot;
 }
&lt;p&gt;;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;var match = ...&lt;/p&gt;

&lt;p&gt;var group = ...&lt;/p&gt;

&lt;p&gt;var stages = new BsonDocument[] {match, group};&lt;br/&gt;
 var pipeline = PipelineDefinition&amp;lt;BsonDocument,BsonDocument&amp;gt;.Create(stages);&lt;/p&gt;

&lt;p&gt;using (var cursor = await collection.AggregateAsync(pipeline, options))&lt;br/&gt;
 {&lt;br/&gt;
&#160; &#160; while (await cursor.MoveNextAsync())&lt;br/&gt;
&#160; &#160; &lt;/p&gt;
{

&#160;

&#160; &#160; &#160;}
&lt;p&gt; }&lt;/p&gt;

&lt;p&gt;I am getting an exception when I try to pass a comment as an aggregation option.&lt;/p&gt;

&lt;p&gt;The error is&#160;&lt;/p&gt;

&lt;p&gt;Command aggregate failed: unrecognized field &apos;comment&apos;.&lt;/p&gt;

&lt;p&gt;The stack trace of the exception is&#160;&lt;/p&gt;

&lt;p&gt;at MongoDB.Driver.Core.WireProtocol.CommandUsingQueryMessageWireProtocol`1.ProcessReply(ConnectionId connectionId, ReplyMessage`1 reply)&lt;br/&gt;
 at MongoDB.Driver.Core.WireProtocol.CommandUsingQueryMessageWireProtocol`1.&amp;lt;ExecuteAsync&amp;gt;d__14.MoveNext()&lt;br/&gt;
&amp;#8212; End of stack trace from previous location where exception was thrown &amp;#8212;&lt;br/&gt;
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&lt;br/&gt;
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&lt;br/&gt;
 at MongoDB.Driver.Core.Servers.Server.ServerChannel.&amp;lt;ExecuteProtocolAsync&amp;gt;d__29`1.MoveNext()&lt;br/&gt;
&amp;#8212; End of stack trace from previous location where exception was thrown &amp;#8212;&lt;br/&gt;
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&lt;br/&gt;
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&lt;br/&gt;
 at MongoDB.Driver.Core.Operations.CommandOperationBase`1.&amp;lt;ExecuteProtocolAsync&amp;gt;d__28.MoveNext()&lt;br/&gt;
&amp;#8212; End of stack trace from previous location where exception was thrown &amp;#8212;&lt;br/&gt;
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&lt;br/&gt;
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&lt;br/&gt;
 at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.&amp;lt;ExecuteAsync&amp;gt;d__2.MoveNext()&lt;br/&gt;
&amp;#8212; End of stack trace from previous location where exception was thrown &amp;#8212;&lt;br/&gt;
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&lt;br/&gt;
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&lt;br/&gt;
 at MongoDB.Driver.Core.Operations.AggregateOperation`1.&amp;lt;ExecuteAsync&amp;gt;d__55.MoveNext()&lt;br/&gt;
&amp;#8212; End of stack trace from previous location where exception was thrown &amp;#8212;&lt;br/&gt;
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&lt;br/&gt;
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&lt;br/&gt;
 at MongoDB.Driver.OperationExecutor.&amp;lt;ExecuteReadOperationAsync&amp;gt;d__3`1.MoveNext()&lt;br/&gt;
&amp;#8212; End of stack trace from previous location where exception was thrown &amp;#8212;&lt;br/&gt;
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&lt;br/&gt;
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&lt;br/&gt;
 at MongoDB.Driver.MongoCollectionImpl`1.&amp;lt;ExecuteReadOperationAsync&amp;gt;d__93`1.MoveNext()&lt;br/&gt;
&amp;#8212; End of stack trace from previous location where exception was thrown &amp;#8212;&lt;br/&gt;
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&lt;br/&gt;
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&lt;br/&gt;
 at MongoDB.Driver.MongoCollectionImpl`1.&amp;lt;AggregateAsync&amp;gt;d__22`1.MoveNext()&lt;br/&gt;
&amp;#8212; End of stack trace from previous location where exception was thrown &amp;#8212;&lt;br/&gt;
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&lt;br/&gt;
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&lt;br/&gt;
 at MongoDB.Driver.MongoCollectionImpl`1.&amp;lt;UsingImplicitSessionAsync&amp;gt;d__101`1.MoveNext()&lt;br/&gt;
&amp;#8212; End of stack trace from previous location where exception was thrown &amp;#8212;&lt;br/&gt;
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&lt;br/&gt;
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&lt;br/&gt;
 at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()&lt;br/&gt;
 at abc.Teste.&amp;lt;GetTeste&amp;gt;d__54.MoveNext() in&#160;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</description>
                <environment></environment>
        <key id="599025">CSHARP-2374</key>
            <summary>Aggregate Option Comment gives an error when doing an AggregateAsync</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</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="9">Done</resolution>
                                        <assignee username="jeff.yemin@mongodb.com">Jeffrey Yemin</assignee>
                                    <reporter username="rribeiro">Rui Ribeiro</reporter>
                        <labels>
                            <label>question</label>
                    </labels>
                <created>Tue, 4 Sep 2018 09:17:58 +0000</created>
                <updated>Fri, 5 Apr 2019 13:58:46 +0000</updated>
                            <resolved>Tue, 11 Sep 2018 12:44:33 +0000</resolved>
                                    <version>2.7.0</version>
                                                    <component>Read Operations</component>
                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="1999196" author="jeff.yemin" created="Tue, 11 Sep 2018 12:44:33 +0000"  >&lt;p&gt;You&apos;re welcome.  Good luck!&lt;/p&gt;</comment>
                            <comment id="1999186" author="rribeiro" created="Tue, 11 Sep 2018 12:35:19 +0000"  >&lt;p&gt;Ok I see&lt;/p&gt;

&lt;p&gt;I need add it as part of the condition.&lt;/p&gt;

&lt;p&gt;Thank you and sorry for my misunderstanding about the property $comment.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="1999141" author="jeff.yemin" created="Tue, 11 Sep 2018 11:36:22 +0000"  >&lt;p&gt;I see.  MongoDB 3.6 introduces comment as a top level argument to the aggregate command:&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;db.test.aggregate([], {comment : &quot;this is my comment&quot;})&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;That&apos;s what the Comment property of AggregateOptions is using.  Your example is adding a comment to the filter specified by the $match stage.  To do that, add the equivalent $comment field to the &quot;match&quot; BsonDocument in your original example instead of using AggregateOptions.Comment.&lt;/p&gt;</comment>
                            <comment id="1999104" author="rribeiro" created="Tue, 11 Sep 2018 10:22:14 +0000"  >&lt;p&gt;Hi&#160;&lt;/p&gt;

&lt;p&gt;In fact I am using version 3.4.&lt;/p&gt;

&lt;p&gt;If you to the documentation for the version 3.4, in this page: &lt;a href=&quot;https://docs.mongodb.com/v3.4/reference/operator/query/comment/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://docs.mongodb.com/v3.4/reference/operator/query/comment/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You have this example:&lt;/p&gt;

&lt;p&gt;db.records.aggregate( [ { $match: { x: &lt;/p&gt;
{ $gt: 0 }
&lt;p&gt;, $comment: &quot;Don&apos;t allow negative inputs.&quot; } }, { $group : { _id: &lt;/p&gt;
{ $mod: [ &quot;$x&quot;, 2 ] }
&lt;p&gt;, total: &lt;/p&gt;
{ $sum: &quot;$x&quot; }
&lt;p&gt; } } ] )&lt;/p&gt;

&lt;p&gt;That it works for me when I run directly on console command, but if try to do this in C# using the driver, I get that error.&lt;/p&gt;

&lt;p&gt;My question is how i can do this using c# mongo driver?&lt;/p&gt;</comment>
                            <comment id="1998385" author="jeff.yemin" created="Mon, 10 Sep 2018 18:23:52 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=rribeiro&quot; class=&quot;user-hover&quot; rel=&quot;rribeiro&quot;&gt;rribeiro&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What version of the MongoDB server are you testing with?  The &lt;a href=&quot;https://docs.mongodb.com/manual/reference/command/aggregate/#aggregate&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;documentation&lt;/a&gt; points out that comment support for aggregation was added in MongoDB 3.6.&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|htxk0f:</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>