Skip to content

Commit e527506

Browse files
committed
MySQL: Numeric data type now supported under decimal column. #3171
1 parent 73cae88 commit e527506

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/Cake/Model/Datasource/Database/Mysql.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class Mysql extends DboSource {
112112
'biginteger' => array('name' => 'bigint', 'limit' => '20'),
113113
'integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'),
114114
'float' => array('name' => 'float', 'formatter' => 'floatval'),
115+
'numeric' => array('name' => 'decimal', 'formatter' => 'floatval'),
115116
'decimal' => array('name' => 'decimal', 'formatter' => 'floatval'),
116117
'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
117118
'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
@@ -767,7 +768,7 @@ public function column($real) {
767768
if (strpos($col, 'float') !== false || strpos($col, 'double') !== false) {
768769
return 'float';
769770
}
770-
if (strpos($col, 'decimal') !== false) {
771+
if (strpos($col, 'decimal') !== false || strpos($col, 'numeric') !== false) {
771772
return 'decimal';
772773
}
773774
if (strpos($col, 'enum') !== false) {

lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,10 @@ public function testColumn() {
547547
$expected = 'decimal';
548548
$this->assertEquals($expected, $result);
549549

550+
$result = $this->Dbo->column('numeric');
551+
$expected = 'decimal';
552+
$this->assertEquals($expected, $result);
553+
550554
$result = $this->Dbo->column('decimal(14,7) unsigned');
551555
$expected = 'decimal';
552556
$this->assertEquals($expected, $result);

0 commit comments

Comments
 (0)