MySQL: Numeric data type now supported under decimal column. #3171

This commit is contained in:
U-Zyn Chua 2013-09-28 23:05:53 +08:00
parent 73cae88a6f
commit e527506c39
2 changed files with 6 additions and 1 deletions

View file

@ -112,6 +112,7 @@ class Mysql extends DboSource {
'biginteger' => array('name' => 'bigint', 'limit' => '20'),
'integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'),
'float' => array('name' => 'float', 'formatter' => 'floatval'),
'numeric' => array('name' => 'decimal', 'formatter' => 'floatval'),
'decimal' => array('name' => 'decimal', 'formatter' => 'floatval'),
'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
@ -767,7 +768,7 @@ class Mysql extends DboSource {
if (strpos($col, 'float') !== false || strpos($col, 'double') !== false) {
return 'float';
}
if (strpos($col, 'decimal') !== false) {
if (strpos($col, 'decimal') !== false || strpos($col, 'numeric') !== false) {
return 'decimal';
}
if (strpos($col, 'enum') !== false) {

View file

@ -547,6 +547,10 @@ class MysqlTest extends CakeTestCase {
$expected = 'decimal';
$this->assertEquals($expected, $result);
$result = $this->Dbo->column('numeric');
$expected = 'decimal';
$this->assertEquals($expected, $result);
$result = $this->Dbo->column('decimal(14,7) unsigned');
$expected = 'decimal';
$this->assertEquals($expected, $result);