Skip to content

Commit

Permalink
MySQL: Numeric data type now supported under decimal column. #3171
Browse files Browse the repository at this point in the history
  • Loading branch information
uzyn committed Sep 28, 2013
1 parent 73cae88 commit e527506
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Cake/Model/Datasource/Database/Mysql.php
Expand Up @@ -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'),
Expand Down Expand Up @@ -767,7 +768,7 @@ public function column($real) {
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) {
Expand Down
4 changes: 4 additions & 0 deletions lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
Expand Up @@ -547,6 +547,10 @@ public function testColumn() {
$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);
Expand Down

0 comments on commit e527506

Please sign in to comment.