<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:37:54 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-811] Update.PushEachWrapped wrap data in a wrong way adding data to a sub array</title>
                <link>https://jira.mongodb.org/browse/CSHARP-811</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;This command:&lt;/p&gt;

&lt;p&gt;var builder = Update.PushEachWrapped(&quot;ArrayData&quot;, new List&amp;lt;GenericListItem&amp;gt;&lt;br/&gt;
                {&lt;br/&gt;
                    new GenericListItem()&lt;/p&gt;
                        {
                            Name = &quot;name&quot;,
                            Surname = &quot;surname&quot;
                        }&lt;br/&gt;
                });&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
It is translated in  :&lt;br/&gt;
&lt;br/&gt;
{ &quot;$push&quot; : { &quot;ArrayData&quot; : { &quot;$each&quot; : [&lt;span class=&quot;error&quot;&gt;&amp;#91;{ &quot;Name&quot; : &quot;name&quot;, &quot;Surname&quot; : &quot;surname&quot; }&amp;#93;&lt;/span&gt;] } } }&lt;br/&gt;
&lt;br/&gt;
that is wrong, due to a [ in sub elements. &lt;br/&gt;
&lt;br/&gt;
The right command translation has to be &lt;br/&gt;
&lt;br/&gt;
{ &quot;$push&quot; : { &quot;ArrayData&quot; : { &quot;$each&quot; : &lt;span class=&quot;error&quot;&gt;&amp;#91;{ &quot;Name&quot; : &quot;name&quot;, &quot;Surname&quot; : &quot;surname&quot; }&amp;#93;&lt;/span&gt; } } }&lt;br/&gt;
&lt;br/&gt;
otherwise a sub array will be created.&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
The same problem is also present in :&lt;br/&gt;
PushAllWrapped&lt;br/&gt;
AddToSetEachWrapped&lt;br/&gt;
PushEachWrapped&lt;br/&gt;
&lt;br/&gt;
There is a possible workaround forcing the conversion between IEnumerable&amp;lt;T&amp;gt; to Array. So re-writing the above code in this way&lt;br/&gt;
&lt;br/&gt;
var builder = Update.PushEachWrapped(&quot;ArrayData&quot;, new List&amp;lt;GenericListItem&amp;gt;&lt;br/&gt;
                {&lt;br/&gt;
                    new GenericListItem()&lt;br/&gt;
                        {                            Name = &quot;name&quot;,                            Surname = &quot;surname&quot;                        }
&lt;p&gt;                }.ToArray());&lt;/p&gt;

&lt;p&gt;create a correct serialization.&lt;/p&gt;


&lt;p&gt;It seems that the problem is located here  in UpdateBuilder.cs&lt;/p&gt;

&lt;p&gt;BsonDocumentWrapper.CreateMultiple(values).Cast&amp;lt;BsonValue&amp;gt;(); &lt;br/&gt;
(public UpdateBuilder PushEachWrapped&amp;lt;T&amp;gt; ... raw 1309 in UpdateBuilder.cs) wrap each values in an array&lt;/p&gt;



</description>
                <environment>.net 4.0</environment>
        <key id="87862">CSHARP-811</key>
            <summary>Update.PushEachWrapped wrap data in a wrong way adding data to a sub array</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="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="lucacasali">Luca casali</reporter>
                        <labels>
                            <label>driver</label>
                    </labels>
                <created>Thu, 29 Aug 2013 13:05:56 +0000</created>
                <updated>Thu, 20 Mar 2014 14:37:23 +0000</updated>
                            <resolved>Tue, 3 Sep 2013 12:14:00 +0000</resolved>
                                    <version>1.8</version>
                    <version>1.8.1</version>
                    <version>1.8.2</version>
                                                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="413988" author="craiggwilson" created="Thu, 29 Aug 2013 14:09:06 +0000"  >&lt;p&gt;This is because the definition of Update.PushEachWrapped&amp;lt;T&amp;gt; takes a generic T parameter. There are 2 overloads for this method:&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;   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;        public UpdateBuilder PushEachWrapped&amp;lt;T&amp;gt;(string name, IEnumerable&amp;lt;T&amp;gt; values);&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;        public UpdateBuilder PushEachWrapped&amp;lt;T&amp;gt;(string name, params T[] values);&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&amp;nbsp;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;As you aren&apos;t specifying what T is, the compiler is using type inference and determining that your type T is a List&amp;lt;GenericListItem&amp;gt; and choosing the second one.  It is entirely plausable that someone would want to push a number of lists into an array, an array of arrays.&lt;/p&gt;

&lt;p&gt;The fix for you is to declare what T is.  &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;Update.PushEachWrapped&amp;lt;GenericListItem&amp;gt;(&quot;ArrayData&quot;, new List&amp;lt;GenericListItem&amp;gt;{ });&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;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></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|hrskkf:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>80567</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>