Issues

ZF-7041: Zend_Db_Adapter returns "double(X, Y) unsigned" instead of "double" for a column DATA_TYPE and voids SCALE and PRECISION keys

Description

I don't know if it's supposed to be like this, but when I try to access the metadata of any random MySQL table which have a DOUBLE field, the Zend_Db_Adapter_Pdo_Mysql returns "double(X, Y) unsigned" instead of "double" for a column DATA_TYPE. Additionnaly, it also voids the SCALE and PRECISION keys in the metadata, which is quite strange because it works perfectly using FLOAT and DECIMAL types.

{quote} array 'SCHEMA_NAME' => null 'TABLE_NAME' => string 'test' (length=4) 'COLUMN_NAME' => string 'float3_3' (length=8) 'COLUMN_POSITION' => int 10 'DATA_TYPE' => string 'float' (length=5) 'DEFAULT' => null 'NULLABLE' => boolean false 'LENGTH' => null 'SCALE' => string '3' (length=1) 'PRECISION' => string '3' (length=1) 'UNSIGNED' => null 'PRIMARY' => boolean false 'PRIMARY_POSITION' => null 'IDENTITY' => boolean false

array 'SCHEMA_NAME' => null 'TABLE_NAME' => string 'test' (length=4) 'COLUMN_NAME' => string 'double5_3' (length=9) 'COLUMN_POSITION' => int 11 'DATA_TYPE' => string 'double(5,3) unsigned' (length=20) 'DEFAULT' => null 'NULLABLE' => boolean false 'LENGTH' => null 'SCALE' => null 'PRECISION' => null 'UNSIGNED' => boolean true 'PRIMARY' => boolean false 'PRIMARY_POSITION' => null 'IDENTITY' => boolean false {quote}

Comments

At the PHP Benelux BugHuntDay 2010 I was focusing on solving this bug and I came out with this patch.

There are many other type of fields suffering by the same behavior, not only DOUBLE, and it is pretty much depending on the used SQL server. I was only focusing on MySQL 5.1 and Sqlite3, thus my patch only address these adapters (MySQLi, PDO-MySQL and PDO-Sqlite).

PDO-Sqlite also have the same misbehavior, but to solve entirely is more complicated, because of the sqlite-affinity and the conversion rules of user-types to internal type and affinity.

Others may want to further contribute on this subject.

The patch contains also relevant unit tests.

Correct me if i wrong but is missing apply the patch to this issue that already was marked how fixed.