Commit 7a73a5ac authored by Benjamin Eberlei's avatar Benjamin Eberlei

[DBAL-298] Fix foreign table names not being quoted correctly.

parent 1e1cdb7e
......@@ -2004,7 +2004,7 @@ abstract class AbstractPlatform
$sql .= implode(', ', $foreignKey->getLocalColumns())
. ') REFERENCES '
. $foreignKey->getForeignTableName() . ' ('
. $foreignKey->getQuotedForeignTableName($this) . ' ('
. implode(', ', $foreignKey->getForeignColumns()) . ')';
return $sql;
......
......@@ -22,6 +22,7 @@
namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Schema\Visitor\Visitor;
use Doctrine\DBAL\Platforms\AbstractPlatform;
class ForeignKeyConstraint extends AbstractAsset implements Constraint
{
......@@ -109,6 +110,24 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
return $this->_foreignTableName;
}
/**
* Get the quoted representation of this asset but only if it was defined with one. Otherwise
* return the plain unquoted value as inserted.
*
* @param AbstractPlatform $platform
* @return string
*/
public function getQuotedForeignTableName(AbstractPlatform $platform)
{
$keywords = $platform->getReservedKeywordsList();
$parts = explode(".", $this->getForeignTableName());
foreach ($parts AS $k => $v) {
$parts[$k] = ($this->_quoted || $keywords->isKeyword($v)) ? $platform->quoteIdentifier($v) : $v;
}
return implode(".", $parts);
}
/**
* @return array
*/
......
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