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

Bug #10057 function createConstraint fails to set $type
Submitted: 2007-02-08 14:01 UTC Modified: 2007-02-16 10:51 UTC
From: ooglek Assigned: quipo
Status: Closed Package: MDB2_Driver_mysql (version 1.3.0)
PHP Version: 5.1.6 OS: FreeBSD 6.x
Roadmaps: (Not assigned)    
Subscription  


 [2007-02-08 14:01 UTC] ooglek (Peter Beckman)
Description: ------------ 688 if (!empty($definition['primary'])) { 689 $type = 'PRIMARY'; 690 $name = 'KEY'; 691 } elseif (!empty($definition['unique'])) { 692 $type = 'UNIQUE'; 693 } In some cases, $type is NEVER set, and thus creates bad $query -- "ALTER TABLE $table ADD $type $name" results in invalid query with $type unset. ALTER TABLE foo ADD foo_page_id_id_idx (page_id,id) tries to add a column, not a constraint. $type being empty should throw an error. Test script: --------------- $constraint_name = $langData['table_name'] .'_'. $this->options['string_page_id_col'] .'_'. $this->options['string_id_col']; $constraint_definition = array( 'fields' => array( $this->options['string_page_id_col'] => array(), $this->options['string_id_col'] => array(), ) ); $res = $this->db->manager->createConstraint($langData['table_name'], $constraint_name, $constraint_definition); Expected result: ---------------- Expected an error, due to no type of constraint set. Actual result: -------------- Bad SQL executed on server.

Comments

 [2007-02-16 10:51 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.