Commit 2b7ec08c authored by František Bereň's avatar František Bereň

added test to change decimal precision in pgsql

parent 10376551
...@@ -334,4 +334,52 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase ...@@ -334,4 +334,52 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
$this->assertEquals($expected, $actual); $this->assertEquals($expected, $actual);
} }
} }
public function testAlterDecimalPrecisionScale()
{
$table = new Table('mytable');
$table->addColumn('dfoo1', 'decimal');
$table->addColumn('dfoo2', 'decimal', array('precision' => 10, 'scale' => 6));
$table->addColumn('dfoo3', 'decimal', array('precision' => 10, 'scale' => 6));
$table->addColumn('dfoo4', 'decimal', array('precision' => 10, 'scale' => 6));
$tableDiff = new TableDiff('mytable');
$tableDiff->fromTable = $table;
$tableDiff->changedColumns['dloo1'] = new \Doctrine\DBAL\Schema\ColumnDiff(
'dloo1', new \Doctrine\DBAL\Schema\Column(
'dloo1', \Doctrine\DBAL\Types\Type::getType('decimal'), array('precision' => 16, 'scale' => 6)
),
array('type', 'notnull', 'default')
);
$tableDiff->changedColumns['dloo2'] = new \Doctrine\DBAL\Schema\ColumnDiff(
'dloo2', new \Doctrine\DBAL\Schema\Column(
'dloo2', \Doctrine\DBAL\Types\Type::getType('decimal'), array('precision' => 10, 'scale' => 4)
),
array('type', 'notnull', 'default')
);
$tableDiff->changedColumns['dloo3'] = new \Doctrine\DBAL\Schema\ColumnDiff(
'dloo3', new \Doctrine\DBAL\Schema\Column(
'dloo3', \Doctrine\DBAL\Types\Type::getType('decimal'), array('precision' => 10, 'scale' => 6)
),
array('type', 'notnull', 'default')
);
$tableDiff->changedColumns['dloo4'] = new \Doctrine\DBAL\Schema\ColumnDiff(
'dloo4', new \Doctrine\DBAL\Schema\Column(
'dloo4', \Doctrine\DBAL\Types\Type::getType('decimal'), array('precision' => 16, 'scale' => 8)
),
array('type', 'notnull', 'default')
);
$sql = $this->_platform->getAlterTableSQL($tableDiff);
$expectedSql = array(
'ALTER TABLE mytable ALTER dloo1 TYPE NUMERIC(16, 6)',
'ALTER TABLE mytable ALTER dloo2 TYPE NUMERIC(10, 4)',
'ALTER TABLE mytable ALTER dloo4 TYPE NUMERIC(16, 8)',
);
$this->assertEquals($expectedSql, $sql);
}
} }
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