Skip to content

Commit

Permalink
fix string column type declarations with whitespace on SQLite
Browse files Browse the repository at this point in the history
  • Loading branch information
deeky666 committed Jan 5, 2016
1 parent 1789f01 commit 954b277
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ protected function _getPortableTableColumnList($table, $database, $tableColumns)
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Functional\Schema;

use Doctrine\DBAL\Schema;
use Doctrine\DBAL\Types\Type;

class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
Expand Down Expand Up @@ -156,6 +157,34 @@ public function testNonDefaultPKOrder()
$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
Expand Down

0 comments on commit 954b277

Please sign in to comment.