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

Bug #6054 unsigned fields handling in reverse class
Submitted: 2005-11-24 09:33 UTC
From: alex at cgi-central dot net Assigned: lsmith
Status: Closed Package: MDB2_Driver_mysql
PHP Version: 4.3.11 OS: any
Roadmaps: (Not assigned)    
Subscription  


 [2005-11-24 09:33 UTC] alex at cgi-central dot net
Description: ------------ Reverse driver seems to do not have any handling to determine unsigned fields. Code below adds this handling. Also function name was wrong: getTableConstraintDefinition instead of getTableConstraintsDefinition in base class, this caused all kind of troubles. Test script: --------------- --- MDB2/Driver/Reverse/mysql.php 16 Oct 2005 09:39:50 -0000 1.34 +++ MDB2/Driver/Reverse/mysql.php 24 Nov 2005 09:31:23 -0000 @@ -93,6 +93,7 @@ } if ($field_name == $column['field']) { list($types, $length) = $db->datatype->mapNativeDatatype($column); + $unsigned = preg_match('/ unsigned/i', $column['type']); $notnull = false; if (array_key_exists('null', $column) && $column['null'] != 'YES') { $notnull = true; @@ -120,6 +121,9 @@ if ($default !== false) { $definition[$key]['default'] = $default; } + if ($unsigned) { + $definition[$key]['unsigned'] = 1; + } if ($autoincrement !== false) { $definition[$key]['autoincrement'] = $autoincrement; } @@ -201,7 +205,7 @@ } // }}} - // {{{ getTableConstraintDefinition() + // {{{ getTableConstraintsDefinition() /** * get the stucture of a constraint into an array @@ -211,7 +215,7 @@ * @return mixed data array on success, a MDB2 error on failure * @access public */ - function getTableConstraintDefinition($table, $index_name) + function getTableConstraintsDefinition($table, $index_name) { $db =& $this->getDBInstance(); if (PEAR::isError($db)) { @@ -224,6 +228,7 @@ } $definition = array(); while (is_array($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))) { + if (!($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) || $db->options['field_case'] != CASE_LOWER ) {

Comments

 [2005-11-24 14:21 UTC] lsmith
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. It should be getTableConstraintDefinition() without the "s" .. I also fixed this in the call inside MDB2_Schema. The code for unsigned detection was implemented inside the mapNativeDatatype() Method in the datatype module.