Skip to content

Commit

Permalink
Decimal support for SQLite. #3171
Browse files Browse the repository at this point in the history
  • Loading branch information
uzyn committed Sep 28, 2013
1 parent e0eb8f8 commit c74c8d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Cake/Model/Datasource/Database/Sqlite.php
Expand Up @@ -73,6 +73,7 @@ class Sqlite extends DboSource {
'integer' => array('name' => 'integer', 'limit' => null, 'formatter' => 'intval'),
'biginteger' => array('name' => 'bigint', 'limit' => 20),
'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'),
Expand Down Expand Up @@ -278,7 +279,7 @@ public function column($real) {
return 'binary';
}
if (strpos($col, 'numeric') !== false || strpos($col, 'decimal') !== false) {
return 'float';
return 'decimal';
}
return 'text';
}
Expand Down
6 changes: 6 additions & 0 deletions lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php
Expand Up @@ -363,6 +363,12 @@ public function testDatatypes() {
'default' => '',
'length' => '5,2',
),
'decimal_field' => array(
'type' => 'decimal',
'null' => true,
'default' => '0.000',
'length' => '6,3',
),
'huge_int' => array(
'type' => 'biginteger',
'null' => true,
Expand Down

0 comments on commit c74c8d4

Please sign in to comment.