mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Decimal support for MySQL. #3171
This commit is contained in:
parent
cc5795c67d
commit
7fb51ab50f
2 changed files with 10 additions and 2 deletions
|
@ -112,6 +112,7 @@ class Mysql extends DboSource {
|
||||||
'biginteger' => array('name' => 'bigint', 'limit' => '20'),
|
'biginteger' => array('name' => 'bigint', 'limit' => '20'),
|
||||||
'integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'),
|
'integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'),
|
||||||
'float' => array('name' => 'float', 'formatter' => 'floatval'),
|
'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'),
|
'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'),
|
'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
|
||||||
'time' => array('name' => 'time', 'format' => 'H:i:s', 'formatter' => 'date'),
|
'time' => array('name' => 'time', 'format' => 'H:i:s', 'formatter' => 'date'),
|
||||||
|
@ -763,9 +764,12 @@ class Mysql extends DboSource {
|
||||||
if (strpos($col, 'blob') !== false || $col === 'binary') {
|
if (strpos($col, 'blob') !== false || $col === 'binary') {
|
||||||
return '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';
|
return 'float';
|
||||||
}
|
}
|
||||||
|
if (strpos($col, 'decimal') !== false) {
|
||||||
|
return 'decimal';
|
||||||
|
}
|
||||||
if (strpos($col, 'enum') !== false) {
|
if (strpos($col, 'enum') !== false) {
|
||||||
return "enum($vals)";
|
return "enum($vals)";
|
||||||
}
|
}
|
||||||
|
|
|
@ -543,8 +543,12 @@ class MysqlTest extends CakeTestCase {
|
||||||
$expected = 'float';
|
$expected = 'float';
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
|
$result = $this->Dbo->column('decimal');
|
||||||
|
$expected = 'decimal';
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$result = $this->Dbo->column('decimal(14,7) unsigned');
|
$result = $this->Dbo->column('decimal(14,7) unsigned');
|
||||||
$expected = 'float';
|
$expected = 'decimal';
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue