<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Tue Jun 18 07:05:03 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/DC-875/DC-875.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>[DC-875] One-to-many relationship returns Doctrine_Record instead of Doctrine_Collection</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-875</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;I&apos;ve run into a bit of a snag in my application where a relationship defined as a one-to-many relationship returns a model object (instance of Doctrine_Record) instead of a Doctrine_Collection when I try to access it as $model-&amp;gt;RelatedComponent[] = $child1. This, of course, yields an exception like so:&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;Doctrine_Exception: Add is not supported for AuditLogProperty&lt;/tt&gt;&lt;br/&gt;
    &lt;tt&gt;#0 path\library\Doctrine\Access.php(131): Doctrine_Access-&amp;gt;add(Object(AuditLogProperty))&lt;/tt&gt;&lt;br/&gt;
    &lt;tt&gt;#1 path\application\models\Article.php(58): Doctrine_Access-&amp;gt;offsetSet(NULL, Object(AuditLogProperty))&lt;/tt&gt;&lt;br/&gt;
    &lt;tt&gt;#2 path\library\Doctrine\Record.php(354): Article-&amp;gt;postInsert(Object(Doctrine_Event))&lt;/tt&gt;&lt;br/&gt;
    &lt;tt&gt;#3 path\library\Doctrine\Connection\UnitOfWork.php(576): Doctrine_Record-&amp;gt;invokeSaveHooks(&apos;post&apos;, &apos;insert&apos;, Object(Doctrine_Event))&lt;/tt&gt;&lt;br/&gt;
    &lt;tt&gt;#4 path\library\Doctrine\Connection\UnitOfWork.php(81): Doctrine_Connection_UnitOfWork-&amp;gt;insert(Object(Article))&lt;/tt&gt;&lt;br/&gt;
    &lt;tt&gt;#5 path\library\Doctrine\Record.php(1718): Doctrine_Connection_UnitOfWork-&amp;gt;saveGraph(Object(Article))&lt;/tt&gt;&lt;br/&gt;
    &lt;tt&gt;#6 path\application\modules\my-page\controllers\ArticleController.php(26): Doctrine_Record-&amp;gt;save()&lt;/tt&gt;&lt;br/&gt;
    &lt;tt&gt;#7 path\library\Zend\Controller\Action.php(513): MyPage_ArticleController-&amp;gt;createAction()&lt;/tt&gt;&lt;br/&gt;
    &lt;tt&gt;#8 path\library\Zend\Controller\Dispatcher\Standard.php(289): Zend_Controller_Action-&amp;gt;dispatch(&apos;createAction&apos;)&lt;/tt&gt;&lt;br/&gt;
    &lt;tt&gt;#9 path\library\Zend\Controller\Front.php(946): Zend_Controller_Dispatcher_Standard-&amp;gt;dispatch(Object(Zend_Controller_Request_Http),&lt;/tt&gt; &lt;tt&gt;Object(Zend_Controller_Response_Http))&lt;/tt&gt;&lt;br/&gt;
    &lt;tt&gt;#10 path\library\Zend\Application\Bootstrap\Bootstrap.php(77): Zend_Controller_Front-&amp;gt;dispatch()&lt;/tt&gt;&lt;br/&gt;
    &lt;tt&gt;#11 path\library\Zend\Application.php(358): Zend_Application_Bootstrap_Bootstrap-&amp;gt;run()&lt;/tt&gt;&lt;br/&gt;
    &lt;tt&gt;#12 path\public\index.php(11): Zend_Application-&amp;gt;run()&lt;/tt&gt;&lt;br/&gt;
    {{#13 &lt;/p&gt;
{main}
&lt;p&gt;}}&lt;/p&gt;

&lt;p&gt;This is what my yaml-schema looks like (excerpt):&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;schema.yml&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;AuditLogEntry:
  tableName: audit_log_entries
  actAs:
    Timestampable:
      updated: {disabled: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;}
  columns:
    user_id: {type: integer(8), unsigned: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;, primary: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;}
    id: {type: integer(8), unsigned: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;, primary: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;, autoincrement: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;}
    type: {type: string(255), notnull: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;}
    mode: {type: string(16)}
    article_id: {type: integer(8), unsigned: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;}
    comment_id: {type: integer(8), unsigned: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;}
    question_id: {type: integer(8), unsigned: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;}
    answer_id: {type: integer(8), unsigned: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;}
    message_id: {type: integer(8), unsigned: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;}
  indexes:
#   Must index autoincrementing id-column since it&apos;s a compound primary key and 
#   the auto-incrementing column is not the first column and we use InnoDB.
    id: {fields: [id]}
    type: {fields: [type, mode]}
  relations:
    User:
      local: user_id
      foreign: user_id
      foreignAlias: AuditLogs
      type: one
      onDelete: CASCADE
      onUpdate: CASCADE
AuditLogProperty:
  tableName: audit_log_properties
  columns:
    auditlog_id: {type: integer(8), unsigned: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;, primary: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;}
    prop_id: {type: integer(2), unsigned: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;, primary: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;, &lt;span class=&quot;code-keyword&quot;&gt;default&lt;/span&gt;: 1}
    name: {type: string(255), notnull: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;}
    value: {type: string(1024)}
  relations:
    AuditLogEntry:
      local: auditlog_id
      foreign: id
      type: one
      foreignType: many
      foreignAlias: Properties
      onDelete: CASCADE
      onUpdate: CASCADE
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now, if we look at the generated class-files, it looks fine:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Unable to find source-code formatter for language: php.&lt;/span&gt; Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml&lt;/div&gt;&lt;pre&gt;/**
 * @property integer $user_id
 * @property integer $id
 * @property string $type
 * @property string $mode
 * @property integer $article_id
 * @property integer $comment_id
 * @property integer $question_id
 * @property integer $answer_id
 * @property integer $message_id
 * @property integer $news_comment_id
 * @property User $User
 * @property Doctrine_Collection $Properties
 * @property Doctrine_Collection $Notifications
 */
&lt;span class=&quot;code-keyword&quot;&gt;abstract&lt;/span&gt; class BaseAuditLogEntry &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_Record

/**
 * @property integer $auditlog_id
 * @property integer $prop_id
 * @property string $name
 * @property string $value
 * @property AuditLogEntry $AuditLogEntry
 */
&lt;span class=&quot;code-keyword&quot;&gt;abstract&lt;/span&gt; class BaseAuditLogProperty &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_Record
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;However, when I later try to add properties I get the exception posted in the beginning of the question:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Unable to find source-code formatter for language: php.&lt;/span&gt; Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml&lt;/div&gt;&lt;pre&gt;$auditLog = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; AuditLogEntry();
$prop1 = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; AuditLogProperty();
$prop1-&amp;gt;name = &apos;title&apos;;
$prop1-&amp;gt;value = $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;Content-&amp;gt;title;
$prop2 = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; AuditLogProperty();
$prop2-&amp;gt;name = &apos;length&apos;;
$prop2-&amp;gt;value = count($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;Content-&amp;gt;plainText);
$auditLog-&amp;gt;Properties[] = $prop1;
$auditLog-&amp;gt;Properties[] = $prop2;
$auditLog-&amp;gt;save();
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;If I do the following:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Unable to find source-code formatter for language: php.&lt;/span&gt; Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml&lt;/div&gt;&lt;pre&gt;var_dump(get_class($auditLog-&amp;gt;Properties));
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;I get that &lt;em&gt;Properties&lt;/em&gt; is of type &lt;em&gt;AuditLogProperty&lt;/em&gt;, instead of &lt;em&gt;Doctrine&amp;#95;Collection&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;I use version 1.2.3 of Doctrine.&lt;/p&gt;</description>
                <environment>WAMP:&lt;br/&gt;
Windows 7 - 64bit&lt;br/&gt;
Apache 2.2&lt;br/&gt;
PHP 5.3.1&lt;br/&gt;
MySQL 5.1.41</environment>
            <key id="11965">DC-875</key>
            <summary>One-to-many relationship returns Doctrine_Record instead of Doctrine_Collection</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="patrik.akerstrand">Patrik &#197;kerstrand</reporter>
                        <labels>
                    </labels>
                <created>Thu, 30 Sep 2010 08:22:37 +0000</created>
                <updated>Wed, 14 Sep 2011 23:01:49 +0000</updated>
                                    <version>1.2.3</version>
                                                        <due></due>
                    <votes>1</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="16476" author="twencl" created="Wed, 14 Sep 2011 23:01:49 +0000"  >&lt;p&gt;I am having the same issue and it is killing my application. Using your example, when I call:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;var_dump(get_class($auditLog-&amp;gt;Properties));&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;... and there are no AuditLogProperty records, I would expect either an empty Doctrine_Collection or null, but instead I get a new instance of AuditLogProperty with null values for the properties. &lt;/p&gt;
</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>