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

Request #10233 Set length property when not null, rather than > 0
Submitted: 2007-03-01 11:13 UTC Modified: 2007-03-04 18:44 UTC
From: andrew dot hill at openads dot org Assigned: quipo
Status: Closed Package: MDB2_Driver_mssql (version 1.1.2)
PHP Version: 4.3.11 OS: Centos 4.3, Apache 1.3
Roadmaps: (Not assigned)    

 [2007-03-01 11:13 UTC] andrew dot hill at openads dot org (Andrew Hill)
Description: ------------ In MDB2_Driver_Reverse_mysql::getTableFieldDefinition(), the length property is only set when the returned length value from MDB2_Driver_Datatype_Common::mapNativeDatatype() is > 0. However, it is the responsibility of MDB2_Driver_Datatype_Common::mapNativeDatatype() to ensure that it returns the correct length value, or null. As a result, I would propose that the MDB2_Driver_Reverse_mysql::getTableFieldDefinition() method only check to see if $length is not null, and if so, set the property. This also allows custom data types in MDB2 to sneakily store "alternative" data in the length property - for example, the set of allowed values for an "enum" native type can be returned as the length. Test script: --------------- --- MDB2/Driver/Reverse/mysql.php (revision 4767) +++ MDB2/Driver/Reverse/mysql.php (working copy) @@ -118,7 +118,7 @@ 'notnull' => $notnull, 'nativetype' => preg_replace('/^([a-z]+)[^a-z].*/i', '\\1', $column['type']) ); - if ($length > 0) { + if (!is_null($length)) { $definition[0]['length'] = $length; } if (!is_null($unsigned)) {


 [2007-03-04 18:12 UTC] quipo (Lorenzo Alberton)
is the length property the place for such things?
 [2007-03-04 18:44 UTC] quipo (Lorenzo Alberton)
Apart from the "abuse" of the length property for other purposes, I agree with your remarks. Fixed in CVS.