Commit f3756f8d authored by Guilherme Blanco's avatar Guilherme Blanco

Merge pull request #357 from doctrine/PgSqlSchemaFix

Added support for namespace/schema quoting if it is a reserved keyword.
parents aa6be84b 10c6bc31
This diff is collapsed.
...@@ -95,6 +95,23 @@ abstract class AbstractAsset ...@@ -95,6 +95,23 @@ abstract class AbstractAsset
return $this->_namespace; return $this->_namespace;
} }
/**
* Gets the quoted representation of this namespace asset but only if it was defined with one.
* Otherwise return the plain unquoted namespace value as inserted.
*
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
*
* @return string
*/
public function getQuotedNamespaceName(AbstractPlatform $platform)
{
$keywords = $platform->getReservedKeywordsList();
return ($this->_quoted || $keywords->isKeyword($this->_namespace))
? $platform->quoteIdentifier($this->_namespace)
: $this->_namespace;
}
/** /**
* The shortest name is stripped of the default namespace. All other * The shortest name is stripped of the default namespace. All other
* namespaced elements are returned as full-qualified names. * namespaced elements are returned as full-qualified names.
......
...@@ -105,7 +105,8 @@ class CreateSchemaSqlCollector extends AbstractVisitor ...@@ -105,7 +105,8 @@ class CreateSchemaSqlCollector extends AbstractVisitor
*/ */
private function getNamespace($asset) private function getNamespace($asset)
{ {
$namespace = $asset->getNamespaceName() ?: 'default'; $namespace = $asset->getQuotedNamespaceName($this->platform) ?: 'default';
if ( !isset($this->createTableQueries[$namespace])) { if ( !isset($this->createTableQueries[$namespace])) {
$this->createTableQueries[$namespace] = array(); $this->createTableQueries[$namespace] = array();
$this->createSequenceQueries[$namespace] = array(); $this->createSequenceQueries[$namespace] = 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