Skip to content

Commit

Permalink
Fixed boolean column detection on Oracle
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Dec 4, 2018
1 parent 0e89912 commit 2eec226
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions lib/Doctrine/DBAL/Schema/OracleSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ protected function _getPortableTableColumnDefinition($tableColumn)
}
}

$unsigned = $fixed = null;
$unsigned = $fixed = $precision = $scale = null;

if (! isset($tableColumn['column_name'])) {
$tableColumn['column_name'] = '';
Expand All @@ -146,32 +146,30 @@ protected function _getPortableTableColumnDefinition($tableColumn)
$tableColumn['data_default'] = trim($tableColumn['data_default'], "'");
}

$precision = null;
$scale = null;
if ($tableColumn['data_precision'] !== null) {
$precision = (int) $tableColumn['data_precision'];
}

if ($tableColumn['data_scale'] !== null) {
$scale = (int) $tableColumn['data_scale'];
}

$type = $this->_platform->getDoctrineTypeMapping($dbType);
$type = $this->extractDoctrineTypeFromComment($tableColumn['comments'], $type);
$tableColumn['comments'] = $this->removeDoctrineTypeFromComment($tableColumn['comments'], $type);

switch ($dbType) {
case 'number':
if ($tableColumn['data_precision'] === 20 && $tableColumn['data_scale'] === 0) {
$precision = 20;
$scale = 0;
$type = 'bigint';
} elseif ($tableColumn['data_precision'] === 5 && $tableColumn['data_scale'] === 0) {
$type = 'smallint';
$precision = 5;
$scale = 0;
} elseif ($tableColumn['data_precision'] === 1 && $tableColumn['data_scale'] === 0) {
$precision = 1;
$scale = 0;
$type = 'boolean';
if ($precision === 20 && $scale === 0) {
$type = 'bigint';
} elseif ($precision === 5 && $scale === 0) {
$type = 'smallint';
} elseif ($precision === 1 && $scale === 0) {
$type = 'boolean';
} elseif ($tableColumn['data_scale'] > 0) {
$precision = $tableColumn['data_precision'];
$scale = $tableColumn['data_scale'];
$type = 'decimal';
$type = 'decimal';
}

$length = null;
break;
case 'pls_integer':
Expand Down

0 comments on commit 2eec226

Please sign in to comment.