<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:37: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>[CSHARP-721] Insert fails to set SetIdMember interface members values</title>
                <link>https://jira.mongodb.org/browse/CSHARP-721</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;Using the same code as shown here: &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-708&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/CSHARP-708&lt;/a&gt; I noticed that after updating to the 1.8.1 driver via NuGet that all my unit tests were failing. I tracked this down to the collection.Insert&amp;lt;T&amp;gt;(document) was failing to give an ObjectId value even though the representation was set to ObjectId for an interface member... Before and after the call to Insert the Id property value was null.&lt;/p&gt;

&lt;p&gt;If you need a sample, I can try to put one together.&lt;/p&gt;</description>
                <environment>Windows 8, MongoDB Latest</environment>
        <key id="71173">CSHARP-721</key>
            <summary>Insert fails to set SetIdMember interface members values</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="1" iconUrl="https://jira.mongodb.org/images/icons/priorities/blocker.svg">Blocker - P1</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="craig.wilson@mongodb.com">Craig Wilson</assignee>
                                    <reporter username="bniemyjski">Blake Niemyjski</reporter>
                        <labels>
                    </labels>
                <created>Tue, 9 Apr 2013 04:42:48 +0000</created>
                <updated>Thu, 15 May 2014 20:05:56 +0000</updated>
                            <resolved>Mon, 6 May 2013 16:39:11 +0000</resolved>
                                    <version>1.8.1</version>
                                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="585359" author="bniemyjski" created="Thu, 15 May 2014 20:05:56 +0000"  >&lt;p&gt;Do you have any plans to change this back to the old behavior? Did you have a chance to look into this issue again? &lt;/p&gt;</comment>
                            <comment id="329551" author="craiggwilson" created="Mon, 6 May 2013 16:39:11 +0000"  >&lt;p&gt;Let us know if you come across anything else while doing your tests.  For now I&apos;m going resolve this ticket.&lt;/p&gt;</comment>
                            <comment id="329530" author="bniemyjski" created="Mon, 6 May 2013 16:11:38 +0000"  >&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;It&apos;s all good. I went ahead and updated our solution to use the SetIdGenerator. I&apos;m off to do lots of testing! Thanks again for taking the time to provide samples.&lt;/p&gt;</comment>
                            <comment id="329475" author="craiggwilson" created="Mon, 6 May 2013 15:36:17 +0000"  >&lt;p&gt;In regards to the SetRepresentation, we&apos;ve identified why the behavior is as it is.  While it did behave the way you intended prior to 1.8, this was a side-effect of how mapping was previously done and nothing should have &quot;automatically&quot; happened after AutoMap was called. This is a somewhat irreversible change and will continue to be like this in the foreseeable future.  I&apos;d advise you to adopt one of the accepted ways of handling this above.  i.e. write a custom convention to handle your specific scenarios.  I&apos;ve provided the code to get started with this above and copied here for convenience (&lt;a href=&quot;https://gist.github.com/craiggwilson/5217295&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://gist.github.com/craiggwilson/5217295&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;I apologize for the inconvenience this has caused.  We do try hard to prevent breaking changes for minor releases and this was a scenario we didn&apos;t test for.&lt;/p&gt;</comment>
                            <comment id="329447" author="bniemyjski" created="Mon, 6 May 2013 15:13:24 +0000"  >&lt;p&gt;Has there been any updates on this? We are starting to get blocked on this as various NuGet packages require 1.8.1&lt;/p&gt;</comment>
                            <comment id="313804" author="bniemyjski" created="Mon, 15 Apr 2013 16:47:08 +0000"  >&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;I believe that it should just work like it did in 1.7.x. If you set the representation, it should automatically insert a new ObjectId if one is not specified. I believe that By calling SetRepresentation, it should update the mapping correctly.&lt;/p&gt;</comment>
                            <comment id="310339" author="craiggwilson" created="Wed, 10 Apr 2013 15:46:32 +0000"  >&lt;p&gt;Blake,&lt;br/&gt;
  Thanks for the pull request.  That is so helpful.&lt;/p&gt;

&lt;p&gt;  So, I&apos;m actually unclear as to what the behavior here should be.  I believe this may be a subtle change from the 1.7 branch, so my apologies for that.  When we replaced the convention system in 1.8, the order certain things happened changed a little.  We have a convention for noticing that your Id member is a string and it&apos;s representation is an ObjectId.  You can see it registered here: &lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/blob/master/MongoDB.Bson/Serialization/Conventions/DefaultConventionPack.cs#L44&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-csharp-driver/blob/master/MongoDB.Bson/Serialization/Conventions/DefaultConventionPack.cs#L44&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;  The issue is that this all happens in AutoMap.  In your pull request, you have set the ObjectId representation after all the conventions have run, so there is nothing to set the IdGenerator for this guy any longer.  You can obviously do this manually like this...&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;//...&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;cm.SetIdMember(cm.GetMemberMap(c =&amp;gt; c.Id).SetRepresentation(BsonType.ObjectId).SetIdGenerator(new StringObjectIdGenerator()));&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;&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;//...&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 obviously isn&apos;t of great comfort.  A likely better alternative is for you to write a custom convention for this behavior so you don&apos;t need to do this all the time.  For instance, in the following gist (&lt;a href=&quot;https://gist.github.com/craiggwilson/5217295&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://gist.github.com/craiggwilson/5217295&lt;/a&gt;), you can create a convention that will recognize your particular Id pattern and do it without you needing to manually do anything with entities.  (You could write another one that would take care of automatically setting IgnoreExtraElements to true as well &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;).&lt;/p&gt;

&lt;p&gt;I&apos;ll need to confer with my colleagues about whether or not this is something we are going to fix or not.  Could you let me know your thoughts on the situation and how important it is to you that we resolve this differently that the above options.&lt;/p&gt;

&lt;p&gt;Craig&lt;/p&gt;</comment>
                            <comment id="309417" author="bniemyjski" created="Tue, 9 Apr 2013 15:26:35 +0000"  >&lt;p&gt;Hey,&lt;/p&gt;

&lt;p&gt;I created a pull request here: &lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/pull/155&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-csharp-driver/pull/155&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please note that I haven&apos;t verified the test as working in 1.7.1 but I believe it should. I borrowed from an existing unit test and updated it accordingly...&lt;/p&gt;</comment>
                            <comment id="309298" author="craiggwilson" created="Tue, 9 Apr 2013 12:47:15 +0000"  >&lt;p&gt;Hi Blake,&lt;br/&gt;
  Yes, some code would great.  The code from &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-708&quot; title=&quot;BsonClassMap.SetIdMember fails for lhamda expressions that contain interface members&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-708&quot;&gt;&lt;del&gt;CSHARP-708&lt;/del&gt;&lt;/a&gt; is now in a unit test that is passing (&lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/blob/master/MongoDB.BsonUnitTests/Jira/CSharp708Tests.cs&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-csharp-driver/blob/master/MongoDB.BsonUnitTests/Jira/CSharp708Tests.cs&lt;/a&gt;), so having some more information/other code would be very helpful.&lt;/p&gt;
</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="75752">CSHARP-743</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10011"><![CDATA[Minor Change]]></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|hrn64v:</customfieldvalue>

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