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

Bug #15051 Can't create constraints with field length
Submitted: 2008-11-17 02:33 UTC
From: onokazu Assigned: quipo
Status: Closed Package: MDB2_Driver_mysql (version 1.5.0b1)
PHP Version: 4.4.9 OS: Mac OSX
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 50 - 48 = ?

 
 [2008-11-17 02:33 UTC] onokazu (Kazumi Ono)
Description: ------------ The createConstraint() method does not create constraints with field length. Possible patch below: Test script: --------------- --- MDB2/Driver/Manager/mysql.php 2008-03-15 18:26:34.000000000 +0900 +++ MDB2/Driver/Manager/mysql_patched.php 2008-11-17 11:29:28.000000000 +0900 @@ -960,8 +960,12 @@ $query .= ' FOREIGN KEY'; } $fields = array(); - foreach (array_keys($definition['fields']) as $field) { - $fields[] = $db->quoteIdentifier($field, true); + foreach ($definition['fields'] as $field => $fieldinfo) { + if (!empty($fieldinfo['length'])) { + $fields[] = $db->quoteIdentifier($field, true) . '(' . $fieldinfo['length'] . ')'; + } else { + $fields[] = $db->quoteIdentifier($field, true); + } } $query .= ' ('. implode(', ', $fields) . ')'; if (!empty($definition['foreign'])) {

Comments

 [2008-11-23 20:30 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.