Hello everybody,
I am asking for your opinion before filling a bug report,
since this might be another pebkac.

Symptom :
Generating a database schema definition makes all
integers to have lenght equal to 0. Example :
===============
    'users' =>
    ezcDbSchemaTable::__set_state(array(
       'fields' =>
      array (
        'id' =>
        ezcDbSchemaField::__set_state(array(
           'type' => 'integer',
           'length' => 0,
           'notNull' => true,
           'default' => NULL,
           'autoIncrement' => true,
           'unsigned' => false,
        )),
==============

Cause :
DatabaseScema/handlers/mysql/reader.php line 193, is defined private
function static function convertToGenericType( $typeString, &$typeLength,
&$typePrecision ).
When $typeString value is "int(2)", $genericType (value : "integer") is
returned, and $typeLenght becomes a boolean with value 0.

Workaround :
line 198 :
==============
if ( in_array( $genericType, array( 'text', 'decimal', 'float' ) ) && isset(
$matches[3] ) )
==============
Add 'integer' as an array element so that it becomes :
==============
if ( in_array( $genericType, array( 'text', 'decimal', 'float', 'integer' )
) && isset( $matches[3] ) )
==============

Workaround symptoms :
$typeLenght is correctly filled, integers get the correct lenght value :
==============
        'id' =>
        ezcDbSchemaField::__set_state(array(
           'type' => 'integer',
           'length' => 2,
           'notNull' => true,
           'default' => NULL,
           'autoIncrement' => true,
           'unsigned' => false,
        )),
==============

Even if this is a bug, i doubt that i should submit a patch due to code
simplicity.
However, i highly suspect that this is done on purpose since it's trivial.

Thank you in advance for your support.

James
-- 
Components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/components

Reply via email to