Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.0b4

Bug #12516 error in constraint creation - mysql
Submitted: 2007-11-24 11:38 UTC
From: gzuki Assigned: quipo
Status: Closed Package: MDB2_Driver_mysql
PHP Version: Irrelevant OS: irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2007-11-24 11:38 UTC] gzuki (Mario Gzuk)
Description: ------------ Hi, the contraint creation in mysql produce this sql statement: ALTER TABLE `content_to_grp` ADD FOREIGN KEY `fk_contentgroupid_idx` (`contentgroupid`) REFERENCES `content_grps` (`id`) ON UPDATE CASCADE ON DELETE CASCADE; But it should: http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html ALTER TABLE `content_to_grp` ADD CONSTRAINT `fk_contentgroupid_idx` FOREIGN KEY (`contentgroupid`) REFERENCES `content_grps` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; Test script: --------------- $arr=array( 'primary' => 0, 'unique' => 0, 'foreign' => 1, 'check' => 0, 'fields' => array ( 'contentgroupid' => array( 'position' => 1 ) ), 'references' => array( 'table' => 'content_grps', 'fields' => array( 'id' => array( 'position' => 1 ) ) ), 'deferrable' => 0, 'initiallydeferred' => 0, 'onupdate' => 'CASCADE', 'ondelete' => 'CASCADE' ); $db->mgCreateConstraint('content_to_grp', 'fk_contentgroupid', $arr); Expected result: ---------------- ALTER TABLE `content_to_grp` ADD CONSTRAINT `fk_contentgroupid_idx` FOREIGN KEY (`contentgroupid`) REFERENCES `content_grps` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; Actual result: -------------- ALTER TABLE `content_to_grp` ADD FOREIGN KEY `fk_contentgroupid_idx` (`contentgroupid`) REFERENCES `content_grps` (`id`) ON UPDATE CASCADE ON DELETE CASCADE;

Comments

 [2007-11-24 12:42 UTC] quipo (Lorenzo Alberton)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.