<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Tue May 21 07:00:40 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-377/DC-377.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-377] Cannot delete a taggable record (Taggable Extension)</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-377</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;With Taggable extension, when I try to delete a record using Taggable, I get this exception :&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;23000&amp;#93;&lt;/span&gt;: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`sf_sandbox/article_taggable_tag`, CONSTRAINT `article_taggable_tag_id_article_id` FOREIGN KEY (`id`) REFERENCES `article` (`id`))&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;If I check the sql queries generated by Doctrine, there are not &quot;onDelete CASCADE&quot; for one of relation added by Taggable extension.&lt;/p&gt;

&lt;p&gt;I have write some test cases for reproduce this bug (checking if relation has a property onDelete setted to CASCADE) but I can&apos;t reproduce the thrown exception in test case because sqlite omits queries with constraint. Also, I found how to fix this bug.&lt;/p&gt;

&lt;p&gt;The fix and test cases are available in the file attached to this ticket.&lt;/p&gt;</description>
                <environment>PHP 5.3.1, Mac OS X (10.6), MySQL 5.0.86, Symfony 1.4.1</environment>
            <key id="10647">DC-377</key>
            <summary>Cannot delete a taggable record (Taggable Extension)</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="6" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/closed.png">Closed</status>
                    <resolution id="1">Fixed</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="fabienp">Fabien Pennequin</reporter>
                        <labels>
                    </labels>
                <created>Tue, 22 Dec 2009 17:58:17 +0000</created>
                <updated>Fri, 10 Aug 2012 01:51:22 +0000</updated>
                    <resolved>Mon, 15 Mar 2010 14:40:42 +0000</resolved>
                            <version>1.2.0</version>
                <version>1.2.1</version>
                                <fixVersion>1.2.2</fixVersion>
                                <component>Extensions</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>3</watches>
                        <comments>
                    <comment id="12718" author="deefour" created="Tue, 20 Apr 2010 10:53:16 +0000"  >&lt;p&gt;Hi Jon-&lt;/p&gt;

&lt;p&gt;Where can I find this fix?&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://svn.doctrine-project.org/extensions/Taggable/branches/1.2-1.0&quot; class=&quot;external-link&quot;&gt;http://svn.doctrine-project.org/extensions/Taggable/branches/1.2-1.0&lt;/a&gt; (the link referenced from the docs at &lt;a href=&quot;http://www.doctrine-project.org/extension/Taggable&quot; class=&quot;external-link&quot;&gt;http://www.doctrine-project.org/extension/Taggable&lt;/a&gt;) doesn&apos;t have this fix.&lt;/p&gt;</comment>
                    <comment id="12719" author="deefour" created="Tue, 20 Apr 2010 11:02:40 +0000"  >&lt;p&gt;Sorry, it appears the patch attached above &lt;b&gt;is&lt;/b&gt; in SVN, however this is still broken.&lt;/p&gt;

&lt;p&gt;With Doctrine 1.2.2 sandbox configured to work with MySQL 5.x database on 5.2.10, using the following schema&lt;/p&gt;

&lt;p&gt;{{&lt;br/&gt;
BlogPost:&lt;br/&gt;
  actAs: &lt;span class=&quot;error&quot;&gt;&amp;#91;Taggable&amp;#93;&lt;/span&gt;&lt;br/&gt;
  columns:&lt;br/&gt;
    title:&lt;br/&gt;
      type: string(255)&lt;br/&gt;
      notnull: true&lt;br/&gt;
    description:&lt;br/&gt;
      type: string(255)&lt;br/&gt;
      notnull: true&lt;br/&gt;
}}&lt;/p&gt;

&lt;p&gt;the CASCADE in the constraints for the table being applied the Taggable behavior are still not being applied (see first constraint below)&lt;/p&gt;


&lt;p&gt;{{&lt;br/&gt;
CREATE TABLE `blog_post_taggable_tag` (&lt;br/&gt;
  `id` bigint(20) NOT NULL DEFAULT &apos;0&apos;,&lt;br/&gt;
  `tag_id` bigint(20) NOT NULL DEFAULT &apos;0&apos;,&lt;br/&gt;
  PRIMARY KEY (`id`,`tag_id`),&lt;br/&gt;
  KEY `blog_post_taggable_tag_tag_id_taggable_tag_id` (`tag_id`),&lt;br/&gt;
  CONSTRAINT `blog_post_taggable_tag_id_blog_post_id` FOREIGN KEY (`id`) REFERENCES `blog_post` (`id`),&lt;br/&gt;
  CONSTRAINT `blog_post_taggable_tag_tag_id_taggable_tag_id` FOREIGN KEY (`tag_id`) REFERENCES `taggable_tag` (`id`) ON DELETE CASCADE ON UPDATE CASCADE&lt;br/&gt;
) ENGINE=InnoDB DEFAULT CHARSET=latin1 | &lt;br/&gt;
}}&lt;/p&gt;</comment>
                    <comment id="18480" author="indiekiduk" created="Fri, 10 Aug 2012 01:51:22 +0000"  >&lt;p&gt;I use Doctrine v1.2.4 and created a fix for this problem, change the _options array initialization in Taggable.php to this:&lt;/p&gt;

&lt;p&gt;    protected $_options = array(&lt;br/&gt;
        &apos;builderOptions&apos; =&amp;gt; array(),&lt;br/&gt;
        &apos;tagField&apos;       =&amp;gt; null,&lt;br/&gt;
	&apos;cascadeDelete&apos; =&amp;gt; true&lt;br/&gt;
    );&lt;/p&gt;

&lt;p&gt;This works because parent::buildRelation() calls the buildLocalRelation() method in Generator.php which looks for the cascadeDelete and if true then it adds the necessary CASCADE params, as you can see below:&lt;/p&gt;

&lt;p&gt;public function buildLocalRelation($alias = null)&lt;br/&gt;
    {&lt;br/&gt;
        ...&lt;br/&gt;
        if (isset($this-&amp;gt;_options&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;cascadeDelete&amp;#39;&amp;#93;&lt;/span&gt;) &amp;amp;&amp;amp; $this-&amp;gt;_options&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;cascadeDelete&amp;#39;&amp;#93;&lt;/span&gt; &amp;amp;&amp;amp; ! $this-&amp;gt;_options&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;appLevelDelete&amp;#39;&amp;#93;&lt;/span&gt;) &lt;/p&gt;
{
            $options[&apos;onDelete&apos;] = &apos;CASCADE&apos;;
            $options[&apos;onUpdate&apos;] = &apos;CASCADE&apos;;
        }
&lt;p&gt;     ...&lt;/p&gt;

&lt;p&gt;Now both parts of the taggable relation get the cascade on delete feature. So if you delete a tag OR you delete a post, the row in the taggable_tag table gets deleted too.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10250" name="TaggableConstraintError.patch" size="1817" author="fabienp" created="Tue, 22 Dec 2009 17:58:17 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>