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-16 21:33 UTC Modified: 2008-11-23 15:30 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  


 [2008-11-16 21: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 15: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.