<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Wed Jun 19 00:53: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/DC-1057/DC-1057.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-1057] Inserts instead of updates for related objects</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-1057</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Ok, so the object relations go like this:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Comparison
	&lt;ul&gt;
		&lt;li&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;1:N&amp;#93;&lt;/span&gt; Product (FK:comparison_id)
		&lt;ul&gt;
			&lt;li&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;1:N&amp;#93;&lt;/span&gt; Rules (FK:product_id, FK:option_id)&lt;/li&gt;
			&lt;li&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;1:N&amp;#93;&lt;/span&gt; Parameters (FK:product_id)
			&lt;ul&gt;
				&lt;li&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;1:N&amp;#93;&lt;/span&gt; Options (FK:parameter_id)&lt;/li&gt;
			&lt;/ul&gt;
			&lt;/li&gt;
		&lt;/ul&gt;
		&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;The testing code looks like following:&lt;/p&gt;

&lt;p&gt;== CODE START ==&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;
$comp = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Application_Model_Comparison();

/* Filling $comp with data */

&lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; ($i = 0; $i &amp;lt; 10; $i++) {

    $product = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Application_Model_Product();

    &lt;span class=&quot;code-comment&quot;&gt;// Options referenced in Rules
&lt;/span&gt;    $options = array();

    &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; ($j = 0; $j &amp;lt; 10; $j++) {

        $param = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Application_Model_Parameter();

        &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; ($k = 0; $k &amp;lt; 10; $k++) {

            $option = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Application_Model_Option();

            $param-&amp;gt;Options-&amp;gt;add($option);

            &lt;span class=&quot;code-comment&quot;&gt;// Register a single option &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; parameter
&lt;/span&gt;            &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (!isset($options[$j])) {
                $options[$j] = $option;
            }
        }

        $product-&amp;gt;Parameters-&amp;gt;add($param);
    }

    &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; ($j = 0; $j &amp;lt; 10; $j++) {
        $rule = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Application_Model_Rule();

        $rule-&amp;gt;Option = $options[$j];
        $product-&amp;gt;Rules-&amp;gt;add($rule);
    }

    $comp-&amp;gt;Products-&amp;gt;add($product);
}

/**
 * The first save() goes nicely, all objects
 * are created (INSERTed)
 */ 

$comp-&amp;gt;save();

&lt;span class=&quot;code-comment&quot;&gt;// Remove every second product
&lt;/span&gt;$pCount = $comp-&amp;gt;Products-&amp;gt;count();

&lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; ($i = 0; $i &amp;lt; $pCount; $i += 2) {
    $comp-&amp;gt;Products-&amp;gt;remove($i);
}

/**
 * Fails &lt;span class=&quot;code-keyword&quot;&gt;while&lt;/span&gt; trying to save
 *
 * Comparison-&amp;gt;Product-&amp;gt;Parameter-&amp;gt;Option
 * INSERT ... `parameter_id` cannot be NULL
 *
 * Comparison-&amp;gt;Product-&amp;gt;Rule
 * INSERT ... `product_id` cannot be NULL
 */

$comp-&amp;gt;save();
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;== CODE END ==&lt;/p&gt;

&lt;p&gt;The first save() cleans up the relation information in the graph. All child objects are INSERTED instead of UPDATE.&lt;/p&gt;</description>
                <environment>linux, apache2, php 5.3</environment>
            <key id="13870">DC-1057</key>
            <summary>Inserts instead of updates for related objects</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="romanb">Roman S. Borschel</assignee>
                                <reporter username="grisha">Grzegorz Godlewski</reporter>
                        <labels>
                    </labels>
                <created>Fri, 20 Jul 2012 09:36:53 +0000</created>
                <updated>Fri, 20 Jul 2012 09:41:36 +0000</updated>
                                    <version>1.2.4</version>
                                                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>