Commit 6f0ac57c authored by Bill Schaller's avatar Bill Schaller

Merge pull request #2272 from deeky666/DBAL-1779

[DBAL-1779] Fix string column type declarations with whitespace on SQLite

wheee
parents 1789f01c 954b2770
...@@ -269,7 +269,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -269,7 +269,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
protected function _getPortableTableColumnDefinition($tableColumn) protected function _getPortableTableColumnDefinition($tableColumn)
{ {
$parts = explode('(', $tableColumn['type']); $parts = explode('(', $tableColumn['type']);
$tableColumn['type'] = $parts[0]; $tableColumn['type'] = trim($parts[0]);
if (isset($parts[1])) { if (isset($parts[1])) {
$length = trim($parts[1], ')'); $length = trim($parts[1], ')');
$tableColumn['length'] = $length; $tableColumn['length'] = $length;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Functional\Schema; namespace Doctrine\Tests\DBAL\Functional\Schema;
use Doctrine\DBAL\Schema; use Doctrine\DBAL\Schema;
use Doctrine\DBAL\Types\Type;
class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
{ {
...@@ -156,6 +157,34 @@ EOS ...@@ -156,6 +157,34 @@ EOS
$this->assertEquals(array('other_id', 'id'), array_map('strtolower', $tableIndexes['primary']->getColumns())); $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 * @dataProvider getDiffListIntegerAutoincrementTableColumnsData
* @group DBAL-924 * @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