Commit 2a7faab7 authored by Steve Müller's avatar Steve Müller

fix string column type declarations with whitespace on SQLite

fixes #1339
closes #921
parent 8f7e5c5a
......@@ -269,7 +269,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
protected function _getPortableTableColumnDefinition($tableColumn)
{
$parts = explode('(', $tableColumn['type']);
$tableColumn['type'] = $parts[0];
$tableColumn['type'] = trim($parts[0]);
if (isset($parts[1])) {
$length = trim($parts[1], ')');
$tableColumn['length'] = $length;
......
......@@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Functional\Schema;
use Doctrine\DBAL\Schema;
use Doctrine\DBAL\Types\Type;
require_once __DIR__ . '/../../../TestInit.php';
......@@ -158,6 +159,34 @@ EOS
$this->assertEquals(array('other_id', 'id'), array_map('strtolower', $tableIndexes['primary']->getColumns()));
}
/**
* @group DBAL-1779
*/
public function testListTableColumnsWithWhitespacesInTypeDeclarations()
{
$sql = <<<SQL
CREATE TABLE dbal_1779 (
foo VARCHAR (64) ,
bar TEXT (100)
)
SQL;
$this->_conn->executeQuery($sql);
$columns = $this->_sm->listTableColumns('dbal_1779');
$this->assertCount(2, $columns);
$this->assertArrayHasKey('foo', $columns);
$this->assertArrayHasKey('bar', $columns);
$this->assertSame(Type::getType(Type::STRING), $columns['foo']->getType());
$this->assertSame(Type::getType(Type::TEXT), $columns['bar']->getType());
$this->assertSame(64, $columns['foo']->getLength());
$this->assertSame(100, $columns['bar']->getLength());
}
/**
* @dataProvider getDiffListIntegerAutoincrementTableColumnsData
* @group DBAL-924
......
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