<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:35:45 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-81] Generate ObjectId to wrong property when BsonId property is in the parent class</title>
                <link>https://jira.mongodb.org/browse/CSHARP-81</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;Moved from: &lt;a href=&quot;http://github.com/mongodb/mongo-csharp-driver/issues#issue/5&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/mongodb/mongo-csharp-driver/issues#issue/5&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;I think this is not the correct result. Please see the following code:&lt;/p&gt;

&lt;p&gt;public class BaseModel&lt;br/&gt;
{ &lt;span class=&quot;error&quot;&gt;&amp;#91;BsonId&amp;#93;&lt;/span&gt; public ObjectId Id &lt;/p&gt;
{ get; set; } }&lt;br/&gt;
&lt;br/&gt;
public class User : BaseModel&lt;br/&gt;
{ public ObjectId FriendId { get; set; }
&lt;p&gt; }&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;TestFixture&amp;#93;&lt;/span&gt; public class Test&lt;br/&gt;
{ &lt;span class=&quot;error&quot;&gt;&amp;#91;Test&amp;#93;&lt;/span&gt; public void New() &lt;/p&gt;
{

... // create collections
var model = new User();
collection.Save(model);

}
&lt;p&gt; }&lt;/p&gt;

&lt;p&gt;The result in mongodb is:&lt;/p&gt;

&lt;p&gt;    db.user.find() &lt;/p&gt;
{ &quot;FriendId&quot; : ObjectId(&quot;xxxxxxxxxxxxxxxxxxxxxxx&quot;), &quot;_id&quot; : ObjectId(&quot;0000000000000000000&quot;) }

&lt;p&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;I modified above code from my real code so the result might not be the same order but the point is in my result, new object id is assigned to wrong property&amp;#93;&lt;/span&gt;&lt;/p&gt;</description>
                <environment></environment>
        <key id="13469">CSHARP-81</key>
            <summary>Generate ObjectId to wrong property when BsonId property is in the parent class</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="robert@mongodb.com">Robert Stam</assignee>
                                    <reporter username="robert@mongodb.com">Robert Stam</reporter>
                        <labels>
                    </labels>
                <created>Fri, 22 Oct 2010 19:38:29 +0000</created>
                <updated>Wed, 19 Oct 2016 14:16:08 +0000</updated>
                            <resolved>Fri, 22 Oct 2010 21:25:45 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="19534" author="ensecoz" created="Fri, 22 Oct 2010 22:42:28 +0000"  >&lt;p&gt;Regarding the guess: To me, I don&apos;t think guessing is good. The driver should let&apos;s user decides which one is the Id property by either using &lt;span class=&quot;error&quot;&gt;&amp;#91;BsonId&amp;#93;&lt;/span&gt; or specify with Mapping.&lt;/p&gt;

&lt;p&gt;To newbie person like me, the consequence of guessing wrong will be that I will have to waste sometime finding the bug which I am not aware before.&lt;/p&gt;

&lt;p&gt;Anyway, thank for the fixed.&lt;/p&gt;</comment>
                            <comment id="19530" author="rstam" created="Fri, 22 Oct 2010 21:25:45 +0000"  >&lt;p&gt;Fixed bug and added a unit test for this. The Id property now comes from the highest class in the inheritance tree that is able to provide one. The algorithm for detecting an Id field is pretty basic (first field found ending in &quot;Id&quot; or &quot;id&quot; or of type ObjectId or Guid), but of course using the &lt;span class=&quot;error&quot;&gt;&amp;#91;BsonId&amp;#93;&lt;/span&gt; attribute makes guessing unnecessary.&lt;/p&gt;

&lt;p&gt;I&apos;m wondering whether we should even try to guess at the Id property. What are the consequences of guessing wrong?&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|hrh9sv:</customfieldvalue>

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