Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jan 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably needs also a testListTableColumnsWithoutWhitespacesInTypeDeclarations, too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zeroedin-bill this is already covered by all the other DBAL tests

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k

{
$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