Skip to content

Commit

Permalink
Merge branch 'DBAL-149' into 2.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Aug 29, 2011
2 parents 22f88e0 + 71e4ae5 commit 8bda3e9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
Expand Up @@ -1002,7 +1002,7 @@ public function quoteIdentifier($str)
{
$c = $this->getIdentifierQuoteCharacter();

return $c . $str . $c;
return $c . str_replace($c, $c.$c, $str) . $c;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
Expand Up @@ -786,6 +786,6 @@ public function getForUpdateSQL()
*/
public function quoteIdentifier($str)
{
return "[" . $str . "]";
return "[" . str_replace("]", "][", $str) . "]";
}
}
10 changes: 10 additions & 0 deletions tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
Expand Up @@ -16,6 +16,16 @@ public function setUp()
$this->_platform = $this->createPlatform();
}

public function testQuoteIdentifier()
{
if ($this->_platform->getName() == "mssql") {
$this->markTestSkipped('Not working this way on mssql.');
}

$c = $this->_platform->getIdentifierQuoteCharacter();
$this->assertEquals(str_repeat($c, 4), $this->_platform->quoteIdentifier($c));
}

public function testGetInvalidtForeignKeyReferentialActionSQL()
{
$this->setExpectedException('InvalidArgumentException');
Expand Down
4 changes: 4 additions & 0 deletions tests/Doctrine/Tests/DBAL/Platforms/MsSqlPlatformTest.php
Expand Up @@ -171,4 +171,8 @@ public function testModifyLimitQueryWithDescOrderBy()
$this->assertEquals('SELECT TOP 10 * FROM user ORDER BY username DESC', $sql);
}

public function testQuoteIdentifier()
{
$this->assertEquals('[fo][o]', $this->_platform->quoteIdentifier('fo]o'));
}
}

0 comments on commit 8bda3e9

Please sign in to comment.