Commit 7d88ff72 authored by Steve Müller's avatar Steve Müller

Merge pull request #751 from SenseException/postgre-char-fix

[DBAL-1087] Length of fixed string type (char) is ignored on Postgre schema update

Close #751
parents 6d766f61 36ec0caa
......@@ -273,7 +273,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
{
$tableColumn = array_change_key_case($tableColumn, CASE_LOWER);
if (strtolower($tableColumn['type']) === 'varchar') {
if (strtolower($tableColumn['type']) === 'varchar' || strtolower($tableColumn['type']) === 'bpchar') {
// get length from varchar definition
$length = preg_replace('~.*\(([0-9]*)\).*~', '$1', $tableColumn['complete_type']);
$tableColumn['length'] = $length;
......
......@@ -196,6 +196,26 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this->assertInternalType('array', $columns['baz3']->getPlatformOptions());
}
/**
* @group DBAL-1078
*/
public function testListTableColumnsWithFixedStringColumn()
{
$tableName = 'test_list_table_fixed_string';
$table = new Table($tableName);
$table->addColumn('column_char', 'string', array('fixed' => true, 'length' => 2));
$this->_sm->createTable($table);
$columns = $this->_sm->listTableColumns($tableName);
$this->assertArrayHasKey('column_char', $columns);
$this->assertInstanceOf('Doctrine\DBAL\Types\StringType', $columns['column_char']->getType());
$this->assertTrue($columns['column_char']->getFixed());
$this->assertSame(2, $columns['column_char']->getLength());
}
public function testListTableColumnsDispatchEvent()
{
$table = $this->createListTableColumns();
......
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