Skip to content

Commit

Permalink
Fixes a bug caused by unquoted reserved table name being referenced d…
Browse files Browse the repository at this point in the history
…uring schema creation
  • Loading branch information
klaussilveira committed Jul 5, 2012
1 parent ab57a01 commit fe9d93d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
Expand Up @@ -2004,7 +2004,7 @@ public function getForeignKeyBaseDeclarationSQL(ForeignKeyConstraint $foreignKey

$sql .= implode(', ', $foreignKey->getLocalColumns())
. ') REFERENCES '
. $foreignKey->getForeignTableName() . ' ('
. $foreignKey->getQuotedForeignTableName($this) . ' ('
. implode(', ', $foreignKey->getForeignColumns()) . ')';

return $sql;
Expand Down
18 changes: 18 additions & 0 deletions lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php
Expand Up @@ -109,6 +109,24 @@ public function getForeignTableName()
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
*/
Expand Down

0 comments on commit fe9d93d

Please sign in to comment.