<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Thu Jun 20 08:15:20 UTC 2013

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 add field=key&field=summary to the URL of your request.
For example:
http://www.doctrine-project.org/jira/si/jira.issueviews:issue-xml/MODM-123/MODM-123.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Doctrine Project</title>
    <link>http://www.doctrine-project.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>5.2.7</version>
        <build-number>850</build-number>
        <build-date>21-02-2013</build-date>
    </build-info>

<item>
            <title>[MODM-123] Single Collection Inheritance : hydration won&apos;t work properly</title>
                <link>http://www.doctrine-project.org/jira/browse/MODM-123</link>
                <project id="10044" key="MODM">Doctrine MongoDB ODM</project>
                        <description>&lt;p&gt;There is still a problem with Single Collection Inheritance. &lt;/p&gt;

&lt;p&gt;Please consider the following code : &lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
/**
 * @Document(db=&quot;forum&quot;, collection=&quot;Items&quot;)
 * @InheritanceType(&quot;SINGLE_COLLECTION&quot;)
 * @DiscriminatorField(fieldName=&quot;type&quot;)
 * @DiscriminatorMap({0=&quot;Items&quot;, 1=&quot;Stuffs&quot;})
*/
class Items
{
    /**
     *
     * @id
     */
    public $id;

    /**
     * @String
     */
    public $title;
}



/**
 * @Document(db=&quot;forum&quot;, collection=&quot;Items&quot;)
*/
class Stuffs extends Items
{
    
    /**
     *
     * @id
     */
    public $id;

    /**
     * @String
     */
    public $stuffname;

}

$a = new Stuffs();
$a-&amp;gt;stuffname = &apos;TTT&apos;;
$dm-&amp;gt;persist($a);
$dm-&amp;gt;flush();
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 

&lt;p&gt;Resulting in the database with :&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
{
   &quot;_id&quot;: ObjectId(&quot;4d5dd082b53251b84e000000&quot;),
   &quot;stuffname&quot;: &quot;TTT&quot;,
   &quot;type&quot;: 1 
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 
&lt;p&gt;Now if I do :&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
$result = $dm-&amp;gt;find(&apos;Items&apos;, $a-&amp;gt;id);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 
&lt;p&gt;then $result is an instance of &lt;b&gt;Stuffs&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;But if I try :&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
$result = $dm-&amp;gt;find(&apos;Items&apos;, &apos;4d5dd082b53251b84e000000&apos;); 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 
&lt;p&gt;then $result is an instance of &lt;b&gt;Items&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Note that &apos;$a-&amp;gt;id&apos; is a string, the same string containing &apos;4d5dd082b53251b84e000000&apos;, so :&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
$result = $dm-&amp;gt;find(&apos;Items&apos;, $a-&amp;gt;id); 
$result = $dm-&amp;gt;find(&apos;Items&apos;, &apos;4d5dd082b53251b84e000000&apos;); 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 
&lt;p&gt;are semantically equivalent. It seems however that hydration would ignore the DiscriminatorMap in the second example. &lt;/p&gt;

&lt;p&gt;However If you do :&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
$result = $dm-&amp;gt;find(&apos;Stuffs&apos;, &apos;4d5dd082b53251b84e000000&apos;); 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 
&lt;p&gt;You&apos;ll get a &lt;b&gt;Stuffs&lt;/b&gt; as a result. &lt;/p&gt;


&lt;p&gt;Now I tried to find a workaround when you don&apos;t know the type of the returned object. My initial intention was to first fetch a document with :&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
$result = $dm-&amp;gt;find(&apos;Items&apos;, &apos;4d5dd082b53251b84e000000&apos;); 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 
&lt;p&gt;Then I&apos;m testing a property in the objet to see if it&apos;s a &lt;b&gt;Stuffs&lt;/b&gt;, if it is, I tried an new : &lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
$result = $dm-&amp;gt;find(&apos;Stuffs&apos;, &apos;4d5dd082b53251b84e000000&apos;); 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 
&lt;p&gt;In order to fetch a &lt;b&gt;Stuffs&lt;/b&gt;. But ... I still get a *Items&quot;!&lt;/p&gt;

&lt;p&gt;So basically, if you do :&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
$result = $dm-&amp;gt;find(&apos;Stuffs&apos;, &apos;4d5dd082b53251b84e000000&apos;); 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 
&lt;p&gt;You get a &lt;b&gt;Stuffs&lt;/b&gt;. But if you do :&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
$dm-&amp;gt;find(&apos;Items&apos;, &apos;4d5dd082b53251b84e000000&apos;); 
$result = $dm-&amp;gt;find(&apos;Stuffs&apos;, &apos;4d5dd082b53251b84e000000&apos;); 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 
&lt;p&gt;You get a &lt;b&gt;Items&lt;/b&gt;!&lt;/p&gt;</description>
                <environment>Mac OS X, MAMP</environment>
            <key id="12403">MODM-123</key>
            <summary>Single Collection Inheritance : hydration won&apos;t work properly</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/blocker.png">Blocker</priority>
                    <status id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/resolved.png">Resolved</status>
                    <resolution id="1">Fixed</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="billybob">Billy Bob</reporter>
                        <labels>
                    </labels>
                <created>Thu, 17 Feb 2011 21:10:22 +0000</created>
                <updated>Wed, 23 Feb 2011 23:46:37 +0000</updated>
                    <resolved>Wed, 23 Feb 2011 23:46:37 +0000</resolved>
                            <version>1.0.0BETA2</version>
                                <fixVersion>1.0.0BETA2</fixVersion>
                                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="15335" author="jwage" created="Fri, 18 Feb 2011 00:58:47 +0000"  >&lt;p&gt;Hi, can you make a phpunit testcase here? &lt;a href=&quot;https://github.com/doctrine/mongodb-odm/tree/master/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/mongodb-odm/tree/master/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="15341" author="billybob" created="Fri, 18 Feb 2011 19:15:52 +0000"  >&lt;p&gt;Sorry but I&apos;m not familiar with phpunit. &lt;/p&gt;

&lt;p&gt;If that can help, I&apos;ve made more tests here. Strangely when I deleted all the documents in the test base and created new ones, the hydration then worken properly! However in my real project, the issue is still here ...&lt;/p&gt;

&lt;p&gt;In conclusion it seems that the issue is random. &lt;/p&gt;
</comment>
                    <comment id="15343" author="jwage" created="Sat, 19 Feb 2011 18:15:49 +0000"  >&lt;p&gt;I am not able to produce the issue here. Can you make a executable test that I can run so that I can see what you see?&lt;/p&gt;</comment>
                    <comment id="15366" author="billybob" created="Wed, 23 Feb 2011 23:46:37 +0000"  >&lt;p&gt;Doesn&apos;t seem to be an issue in BETA2.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>