BUG Fix decimal not supporting non-integer values

This commit is contained in:
Damian Mooyman 2015-11-02 18:37:20 +13:00
parent 28160fa065
commit 2b3da3c9a8
2 changed files with 12 additions and 4 deletions

View File

@ -7,7 +7,15 @@ php:
env: env:
matrix: matrix:
- DB=POSTGRESQL CORE_RELEASE=master - DB=POSTGRESQL CORE_RELEASE=3.2
matrix:
include:
- php: 5.6
env: DB=POSTGRESQL CORE_RELEASE=3.2
- php: 5.5
env: DB=POSTGRESQL CORE_RELEASE=3
before_script: before_script:
- composer self-update || true - composer self-update || true

View File

@ -442,7 +442,7 @@ class PostgreSQLSchemaManager extends DBSchemaManager {
// TODO: this returns an empty array for the following string: int(11) not null auto_increment // TODO: this returns an empty array for the following string: int(11) not null auto_increment
// on second thoughts, why is an auto_increment field being passed through? // on second thoughts, why is an auto_increment field being passed through?
$pattern = '/^([\w()]+)\s?((?:not\s)?null)?\s?(default\s[\w\']+)?\s?(check\s[\w()\'",\s]+)?$/i'; $pattern = '/^([\w(\,)]+)\s?((?:not\s)?null)?\s?(default\s[\w\.\']+)?\s?(check\s[\w()\'",\s]+)?$/i';
preg_match($pattern, $colSpec, $matches); preg_match($pattern, $colSpec, $matches);
if(sizeof($matches)==0) return ''; if(sizeof($matches)==0) return '';
@ -598,7 +598,7 @@ class PostgreSQLSchemaManager extends DBSchemaManager {
break; break;
case 'numeric': case 'numeric':
$output[$field['column_name']]='decimal(' . $field['numeric_precision'] . ',' . $field['numeric_scale'] . ') default ' . (int)$field['column_default']; $output[$field['column_name']]='decimal(' . $field['numeric_precision'] . ',' . $field['numeric_scale'] . ') default ' . floatval($field['column_default']);
break; break;
case 'integer': case 'integer':
@ -1026,7 +1026,7 @@ class PostgreSQLSchemaManager extends DBSchemaManager {
$defaultValue = ''; $defaultValue = '';
if(isset($values['default']) && is_numeric($values['default'])) { if(isset($values['default']) && is_numeric($values['default'])) {
$defaultValue = ' default ' . $values['default']; $defaultValue = ' default ' . floatval($values['default']);
} }
if($asDbValue) { if($asDbValue) {