Commit 1a9408c5 authored by Steve Müller's avatar Steve Müller

take SQL Server quote characters into account for assets

parent 06b68c02
......@@ -155,7 +155,7 @@ abstract class AbstractAsset
*/
protected function isIdentifierQuoted($identifier)
{
return (isset($identifier[0]) && ($identifier[0] == '`' || $identifier[0] == '"'));
return (isset($identifier[0]) && ($identifier[0] == '`' || $identifier[0] == '"' || $identifier[0] == '['));
}
/**
......@@ -167,7 +167,7 @@ abstract class AbstractAsset
*/
protected function trimQuotes($identifier)
{
return str_replace(array('`', '"'), '', $identifier);
return str_replace(array('`', '"', '[', ']'), '', $identifier);
}
/**
......
......@@ -80,6 +80,7 @@ class ColumnTest extends \PHPUnit_Framework_TestCase
/**
* @group DBAL-64
* @group DBAL-830
*/
public function testQuotedColumnName()
{
......@@ -92,6 +93,35 @@ class ColumnTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('bar', $column->getName());
$this->assertEquals('`bar`', $column->getQuotedName($mysqlPlatform));
$this->assertEquals('"bar"', $column->getQuotedName($sqlitePlatform));
$column = new Column("[bar]", $string);
$sqlServerPlatform = new \Doctrine\DBAL\Platforms\SQLServerPlatform();
$this->assertEquals('bar', $column->getName());
$this->assertEquals('[bar]', $column->getQuotedName($sqlServerPlatform));
}
/**
* @dataProvider getIsQuoted
* @group DBAL-830
*/
public function testIsQuoted($columnName, $isQuoted)
{
$type = Type::getType('string');
$column = new Column($columnName, $type);
$this->assertSame($isQuoted, $column->isQuoted());
}
public function getIsQuoted()
{
return array(
array('bar', false),
array('`bar`', true),
array('"bar"', true),
array('[bar]', true),
);
}
/**
......
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