Permalink
Browse files

Decimal support for PostgreSQL. #3171

  • Loading branch information...
1 parent 7fb51ab commit a1a3e70039cc6bdd43d6bb36cb69829713a6e5f7 @uzyn uzyn committed Sep 28, 2013
@@ -62,6 +62,7 @@ class Postgres extends DboSource {
'integer' => array('name' => 'integer', 'formatter' => 'intval'),
'biginteger' => array('name' => 'bigint', 'limit' => '20'),
'float' => array('name' => 'float', 'formatter' => 'floatval'),
+ 'decimal' => array('name' => 'decimal', 'formatter' => 'floatval'),
'datetime' => 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'),
@@ -665,7 +666,7 @@ public function column($real) {
}
$floats = array(
- 'float', 'float4', 'float8', 'double', 'double precision', 'decimal', 'real', 'numeric'
+ 'float', 'float4', 'float8', 'double', 'double precision', 'real'
);
switch (true) {
@@ -685,6 +686,8 @@ public function column($real) {
return 'text';
case (strpos($col, 'bytea') !== false):
return 'binary';
+ case ($col === 'decimal' || $col === 'numeric'):
+ return 'decimal';
case (in_array($col, $floats)):
return 'float';
default:
@@ -295,6 +295,10 @@ public function testColumnParsing() {
$this->assertEquals('string', $this->Dbo2->column('character varying'));
$this->assertEquals('time', $this->Dbo2->column('time without time zone'));
$this->assertEquals('datetime', $this->Dbo2->column('timestamp without time zone'));
+ $this->assertEquals('decimal', $this->Dbo2->column('decimal'));
+ $this->assertEquals('decimal', $this->Dbo2->column('numeric'));
+ $this->assertEquals('float', $this->Dbo2->column('float'));
+ $this->assertEquals('float', $this->Dbo2->column('double precision'));
$result = $this->Dbo2->column('bigint');
$expected = 'biginteger';

0 comments on commit a1a3e70

Please sign in to comment.