Details
-
Bug
-
Resolution: Unresolved
-
Medium
-
None
-
2011.9
-
None
Description
Here is a simple table for MySQL:
CREATE TABLE `aaaa` (
`test` double unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8
But when I convert it into a db_schema.dba, I get:
<?php // This array contains the database schema $schema = array ( 'aaaa' => array ( 'name' => 'aaaa', 'fields' => array ( 'test' => array ( 'type' => 'double unsigned', 'not_null' => '1', 'default' => false, ), ), 'indexes' => array ( ), ), '_info' => array ( 'format' => 'generic', ), ); ?>
=> The type is parsed as 'double unsigned', it should be 'double' only
It comes from the regex into eZMysqlSchema::parseType, which is currently:
preg_match ( "@([a-z ]*)(\(([0-9]*|[0-9]*,[0-9]*)\))?@", $type_info, $matches );
with the [a-z ], it supposes a type can contain a space! I can assure you it's impossible (you can check all types listed into phpMyAdmin or look -r into http://dev.mysql.com/doc/refman/5.0/en/data-types.html)
Never a mysql type will contain a space, so you should delete it.
Further more, I remember (but not sure) in the past, mysqldump was using uppercases type, and in fact phpMyAdmin shows them as uppercase
=> so, for a security, I would let a-z and A-Z for parsing (hence @i modifier)
code should be:
preg_match ( "@([a-z]*)(\(([0-9]*|[0-9]*,[0-9]*)\))?@i", $type_info, $matches );
a pull request in a few moment...