Permalink
Browse files

Decimal support for MySQL. #3171

  • Loading branch information...
1 parent cc5795c commit 7fb51ab50ffa68f48728c3fc83da44ea33fcb45d @uzyn uzyn committed Sep 28, 2013
@@ -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'),
+ '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'),
'time' => array('name' => 'time', 'format' => 'H:i:s', 'formatter' => 'date'),
@@ -763,9 +764,12 @@ public function column($real) {
if (strpos($col, 'blob') !== false || $col === 'binary') {
return 'binary';
}
- if (strpos($col, 'float') !== false || strpos($col, 'double') !== false || strpos($col, 'decimal') !== false) {
+ if (strpos($col, 'float') !== false || strpos($col, 'double') !== false) {
return 'float';
}
+ if (strpos($col, 'decimal') !== false) {
+ return 'decimal';
+ }
if (strpos($col, 'enum') !== false) {
return "enum($vals)";
}
@@ -543,8 +543,12 @@ public function testColumn() {
$expected = 'float';
$this->assertEquals($expected, $result);
+ $result = $this->Dbo->column('decimal');
+ $expected = 'decimal';
+ $this->assertEquals($expected, $result);
+
$result = $this->Dbo->column('decimal(14,7) unsigned');
- $expected = 'float';
+ $expected = 'decimal';
$this->assertEquals($expected, $result);
}

0 comments on commit 7fb51ab

Please sign in to comment.