Commit adf78836 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge branch 'DBAL-106'

parents ad86e915 c8d97d3e
......@@ -159,6 +159,10 @@ class Column extends AbstractAsset
*/
public function setPrecision($precision)
{
if (!is_numeric($precision)) {
$precision = 10; // defaults to 10 when no valid precision is given.
}
$this->_precision = (int)$precision;
return $this;
}
......@@ -169,7 +173,11 @@ class Column extends AbstractAsset
*/
public function setScale($scale)
{
$this->_scale = $scale;
if (!is_numeric($scale)) {
$scale = 0;
}
$this->_scale = (int)$scale;
return $this;
}
......
......@@ -335,7 +335,7 @@ class Comparator
}
if ($column1->getType() instanceof \Doctrine\DBAL\Types\DecimalType) {
if ($column1->getPrecision() != $column2->getPrecision()) {
if (($column1->getPrecision()?:10) != ($column2->getPrecision()?:10)) {
$changedProperties[] = 'precision';
}
if ($column1->getScale() != $column2->getScale()) {
......
......@@ -653,6 +653,20 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(0, count($tableDiff->removedColumns));
}
/**
* @group DBAL-106
*/
public function testDiffDecimalWithNullPrecision()
{
$column = new Column('foo', Type::getType('decimal'));
$column->setPrecision(null);
$column2 = new Column('foo', Type::getType('decimal'));
$c = new Comparator();
$this->assertEquals(array(), $c->diffColumn($column, $column2));
}
/**
* @param SchemaDiff $diff
* @param int $newTableCount
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment