Commit df6ca602 authored by romanb's avatar romanb

[2.0][DDC-92] Fixed. Patch provided by Christian Heinrich. [DDC-274] Started...

[2.0][DDC-92] Fixed. Patch provided by Christian Heinrich. [DDC-274] Started some method renaming. [DDC-142] Fixed (join column names and discriminator column names dont support quoting) [DDC-258] Fixed.
parent 715da59d
...@@ -32,7 +32,7 @@ namespace Doctrine\Common\Annotations; ...@@ -32,7 +32,7 @@ namespace Doctrine\Common\Annotations;
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class AnnotationException extends \Doctrine\Common\DoctrineException class AnnotationException extends \Doctrine\Common\CommonException
{ {
public static function syntaxError($message) public static function syntaxError($message)
{ {
......
...@@ -106,6 +106,8 @@ class AnnotationReader ...@@ -106,6 +106,8 @@ class AnnotationReader
{ {
$cacheKey = $class->getName() . self::$CACHE_SALT; $cacheKey = $class->getName() . self::$CACHE_SALT;
//FIXME: Just use ->fetch(), otherwise some drivers, i.e. APC will fetch twice because they
// implement contains() in terms of fetch(), *sigh*.
if ($this->_cache->contains($cacheKey)) { if ($this->_cache->contains($cacheKey)) {
return $this->_cache->fetch($cacheKey); return $this->_cache->fetch($cacheKey);
} }
...@@ -141,6 +143,8 @@ class AnnotationReader ...@@ -141,6 +143,8 @@ class AnnotationReader
{ {
$cacheKey = $property->getDeclaringClass()->getName() . '$' . $property->getName() . self::$CACHE_SALT; $cacheKey = $property->getDeclaringClass()->getName() . '$' . $property->getName() . self::$CACHE_SALT;
//FIXME: Just use ->fetch(), otherwise some drivers, i.e. APC will fetch twice because they
// implement contains() in terms of fetch(), *sigh*.
if ($this->_cache->contains($cacheKey)) { if ($this->_cache->contains($cacheKey)) {
return $this->_cache->fetch($cacheKey); return $this->_cache->fetch($cacheKey);
} }
...@@ -177,6 +181,8 @@ class AnnotationReader ...@@ -177,6 +181,8 @@ class AnnotationReader
{ {
$cacheKey = $method->getDeclaringClass()->getName() . '#' . $method->getName() . self::$CACHE_SALT; $cacheKey = $method->getDeclaringClass()->getName() . '#' . $method->getName() . self::$CACHE_SALT;
//FIXME: Just use ->fetch(), otherwise some drivers, i.e. APC will fetch twice because they
// implement contains() in terms of fetch(), *sigh*.
if ($this->_cache->contains($cacheKey)) { if ($this->_cache->contains($cacheKey)) {
return $this->_cache->fetch($cacheKey); return $this->_cache->fetch($cacheKey);
} }
......
...@@ -158,7 +158,7 @@ class Parser ...@@ -158,7 +158,7 @@ class Parser
* *
* @param string $expected Expected string. * @param string $expected Expected string.
* @param array $token Optional token. * @param array $token Optional token.
* @throws Exception * @throws AnnotationException
*/ */
private function syntaxError($expected, $token = null) private function syntaxError($expected, $token = null)
{ {
......
...@@ -21,8 +21,7 @@ ...@@ -21,8 +21,7 @@
namespace Doctrine\Common\Cli; namespace Doctrine\Common\Cli;
use Doctrine\Common\Util\Inflector, use Doctrine\Common\Util\Inflector;
Doctrine\Common\DoctrineException;
/** /**
* Abstract CLI Namespace class * Abstract CLI Namespace class
...@@ -74,7 +73,7 @@ abstract class AbstractNamespace ...@@ -74,7 +73,7 @@ abstract class AbstractNamespace
$name = self::formatName($name); $name = self::formatName($name);
if ($this->hasNamespace($name)) { if ($this->hasNamespace($name)) {
throw DoctrineException::cannotOverrideNamespace($name); throw CliException::cannotOverrideNamespace($name);
} }
return $this->overrideNamespace($name); return $this->overrideNamespace($name);
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
namespace Doctrine\Common\Cli; namespace Doctrine\Common\Cli;
use Doctrine\Common\DoctrineException;
/** /**
* CLI Exception class * CLI Exception class
* *
...@@ -35,7 +33,7 @@ use Doctrine\Common\DoctrineException; ...@@ -35,7 +33,7 @@ use Doctrine\Common\DoctrineException;
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class CliException extends DoctrineException class CliException extends \Doctrine\Common\CommonException
{ {
public static function namespaceDoesNotExist($namespaceName, $namespacePath = '') public static function namespaceDoesNotExist($namespaceName, $namespacePath = '')
{ {
...@@ -54,4 +52,8 @@ class CliException extends DoctrineException ...@@ -54,4 +52,8 @@ class CliException extends DoctrineException
{ {
return new self("Task '{$taskName}' cannot be overriden."); return new self("Task '{$taskName}' cannot be overriden.");
} }
public static function cannotOverrideNamespace($namespace) {
return new self("Namespace '$namespace' cannot be overriden. Call overrideNamespace() directly.");
}
} }
\ No newline at end of file
...@@ -129,7 +129,7 @@ class TaskNamespace extends AbstractNamespace ...@@ -129,7 +129,7 @@ class TaskNamespace extends AbstractNamespace
$name = self::formatName($name); $name = self::formatName($name);
if ($this->hasTask($name)) { if ($this->hasTask($name)) {
throw DoctrineException::cannotOverrideTask($name); throw CliException::cannotOverrideTask($name);
} }
return $this->overrideTask($name, $class); return $this->overrideTask($name, $class);
...@@ -228,7 +228,7 @@ class TaskNamespace extends AbstractNamespace ...@@ -228,7 +228,7 @@ class TaskNamespace extends AbstractNamespace
} else if ($task->validate()) { } else if ($task->validate()) {
$task->run(); $task->run();
} }
} catch (DoctrineException $e) { } catch (CliException $e) {
$message = $this->getFullName() . ':' . $name . ' => ' . $e->getMessage(); $message = $this->getFullName() . ':' . $name . ' => ' . $e->getMessage();
$printer = $this->getPrinter(); $printer = $this->getPrinter();
......
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\Common;
/**
* Base Exception class of Doctrine
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @todo Remove
*/
class DoctrineException extends \Exception
{
/**
* @var array Lazy initialized array of error messages
* @static
*/
private static $_messages = array();
/**
* Initializes a new DoctrineException.
*
* @param string $message
* @param Exception $cause Optional Exception
*/
public function __construct($message = "", \Exception $cause = null)
{
$code = ($cause instanceof Exception) ? $cause->getCode() : 0;
parent::__construct($message, $code, $cause);
}
/**
* Throws a DoctrineException reporting not implemented method in a given class
*
* @static
* @param string $method Method name
* @param string $class Class name
* @throws DoctrineException
*/
public static function notImplemented($method = null, $class = null)
{
if ($method && $class) {
return new self("The method '$method' is not implemented in class '$class'.");
} else if ($method && ! $class) {
return new self($method);
} else {
return new self('Functionality is not implemented.');
}
}
/**
* Implementation of __callStatic magic method.
*
* Received a method name and arguments. It lookups a $_messages HashMap
* for matching Class#Method key and executes the returned string value
* translating the placeholders with arguments passed.
*
* @static
* @param string $method Method name
* @param array $arguments Optional arguments to be translated in placeholders
* @throws DoctrineException
*/
public static function __callStatic($method, $arguments = array())
{
$class = get_called_class();
$messageKey = substr($class, strrpos($class, '\\') + 1) . "#$method";
$end = end($arguments);
$innerException = null;
if ($end instanceof \Exception) {
$innerException = $end;
unset($arguments[count($arguments) - 1]);
}
if (($message = self::getExceptionMessage($messageKey)) !== false) {
$message = sprintf($message, $arguments);
} else {
//$dumper = function ($value) { return var_export($value, true); };
$message = strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $method));
$message = ucfirst(str_replace('_', ' ', $message));
/*if ($arguments) {
$message .= ' (' . implode(', ', array_map($dumper, $arguments)) . ')';
}*/
}
return new $class($message, $innerException);
}
/**
* Retrieves error string given a message key for lookup
*
* @static
* @param string $messageKey
* @return string|false Returns the error string if found; FALSE otherwise
*/
public static function getExceptionMessage($messageKey)
{
if ( ! self::$_messages) {
// Lazy-init messages
self::$_messages = array(
'QueryException#nonUniqueResult' =>
"The query contains more than one result."
);
}
if (isset(self::$_messages[$messageKey])) {
return self::$_messages[$messageKey];
}
return false;
}
}
\ No newline at end of file
...@@ -69,12 +69,12 @@ class GlobalClassLoader ...@@ -69,12 +69,12 @@ class GlobalClassLoader
/** /**
* Installs this class loader on the SPL autoload stack as the only class loader. * Installs this class loader on the SPL autoload stack as the only class loader.
* *
* @throws DoctrineException If the SPL autoload stack already contains other autoloaders. * @throws Exception If the SPL autoload stack already contains other autoloaders.
*/ */
public function register() public function register()
{ {
if (spl_autoload_functions() !== false) { if (spl_autoload_functions() !== false) {
throw new DoctrineException("Autoload stack is not empty. GlobalClassLoader does not work " throw new CommonException("Autoload stack is not empty. GlobalClassLoader does not work "
. "in an autoload stack."); . "in an autoload stack.");
} }
spl_autoload_register(array($this, 'loadClass')); spl_autoload_register(array($this, 'loadClass'));
......
...@@ -409,7 +409,7 @@ class Connection ...@@ -409,7 +409,7 @@ class Connection
{ {
$this->_transactionIsolationLevel = $level; $this->_transactionIsolationLevel = $level;
return $this->executeUpdate($this->_platform->getSetTransactionIsolationSql($level)); return $this->executeUpdate($this->_platform->getSetTransactionIsolationSQL($level));
} }
/** /**
...@@ -493,7 +493,7 @@ class Connection ...@@ -493,7 +493,7 @@ class Connection
*/ */
public function setCharset($charset) public function setCharset($charset)
{ {
$this->executeUpdate($this->_platform->getSetCharsetSql($charset)); $this->executeUpdate($this->_platform->getSetCharsetSQL($charset));
} }
/** /**
......
...@@ -90,7 +90,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -90,7 +90,7 @@ class MsSqlPlatform extends AbstractPlatform
* @param TableDiff $diff * @param TableDiff $diff
* @return array * @return array
*/ */
public function getAlterTableSql(TableDiff $diff) public function getAlterTableSQL(TableDiff $diff)
{ {
$queryParts = array(); $queryParts = array();
if ($diff->newName !== false) { if ($diff->newName !== false) {
...@@ -98,7 +98,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -98,7 +98,7 @@ class MsSqlPlatform extends AbstractPlatform
} }
foreach ($diff->addedColumns AS $fieldName => $column) { foreach ($diff->addedColumns AS $fieldName => $column) {
$queryParts[] = 'ADD ' . $this->getColumnDeclarationSql($column->getName(), $column->toArray()); $queryParts[] = 'ADD ' . $this->getColumnDeclarationSQL($column->getName(), $column->toArray());
} }
foreach ($diff->removedColumns AS $column) { foreach ($diff->removedColumns AS $column) {
...@@ -109,19 +109,19 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -109,19 +109,19 @@ class MsSqlPlatform extends AbstractPlatform
/* @var $columnDiff Doctrine\DBAL\Schema\ColumnDiff */ /* @var $columnDiff Doctrine\DBAL\Schema\ColumnDiff */
$column = $columnDiff->column; $column = $columnDiff->column;
$queryParts[] = 'CHANGE ' . ($columnDiff->oldColumnName) . ' ' $queryParts[] = 'CHANGE ' . ($columnDiff->oldColumnName) . ' '
. $this->getColumnDeclarationSql($column->getName(), $column->toArray()); . $this->getColumnDeclarationSQL($column->getName(), $column->toArray());
} }
foreach ($diff->renamedColumns AS $oldColumnName => $column) { foreach ($diff->renamedColumns AS $oldColumnName => $column) {
$queryParts[] = 'CHANGE ' . $oldColumnName . ' ' $queryParts[] = 'CHANGE ' . $oldColumnName . ' '
. $this->getColumnDeclarationSql($column->getName(), $column->toArray()); . $this->getColumnDeclarationSQL($column->getName(), $column->toArray());
} }
$sql = array(); $sql = array();
if (count($queryParts) > 0) { if (count($queryParts) > 0) {
$sql[] = 'ALTER TABLE ' . $diff->name . ' ' . implode(", ", $queryParts); $sql[] = 'ALTER TABLE ' . $diff->name . ' ' . implode(", ", $queryParts);
} }
$sql = array_merge($sql, $this->_getAlterTableIndexForeignKeySql($diff)); $sql = array_merge($sql, $this->_getAlterTableIndexForeignKeySQL($diff));
return $sql; return $sql;
} }
...@@ -233,12 +233,12 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -233,12 +233,12 @@ class MsSqlPlatform extends AbstractPlatform
return false; return false;
} }
public function getShowDatabasesSql() public function getShowDatabasesSQL()
{ {
return 'SHOW DATABASES'; return 'SHOW DATABASES';
} }
public function getListTablesSql() public function getListTablesSQL()
{ {
return 'SHOW TABLES'; return 'SHOW TABLES';
} }
...@@ -250,7 +250,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -250,7 +250,7 @@ class MsSqlPlatform extends AbstractPlatform
* @return string * @return string
* @override * @override
*/ */
public function getCreateDatabaseSql($name) public function getCreateDatabaseSQL($name)
{ {
return 'CREATE DATABASE ' . $name; return 'CREATE DATABASE ' . $name;
} }
...@@ -262,41 +262,41 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -262,41 +262,41 @@ class MsSqlPlatform extends AbstractPlatform
* @return string * @return string
* @override * @override
*/ */
public function getDropDatabaseSql($name) public function getDropDatabaseSQL($name)
{ {
return 'DROP DATABASE ' . $name; return 'DROP DATABASE ' . $name;
} }
public function getSetTransactionIsolationSql($level) public function getSetTransactionIsolationSQL($level)
{ {
return 'SET TRANSACTION ISOLATION LEVEL ' . $this->_getTransactionIsolationLevelSql($level); return 'SET TRANSACTION ISOLATION LEVEL ' . $this->_getTransactionIsolationLevelSQL($level);
} }
/** /**
* @override * @override
*/ */
public function getIntegerTypeDeclarationSql(array $field) public function getIntegerTypeDeclarationSQL(array $field)
{ {
return 'INT' . $this->_getCommonIntegerTypeDeclarationSql($field); return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
} }
/** /**
* @override * @override
*/ */
public function getBigIntTypeDeclarationSql(array $field) public function getBigIntTypeDeclarationSQL(array $field)
{ {
return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSql($field); return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
} }
/** /**
* @override * @override
*/ */
public function getSmallIntTypeDeclarationSql(array $field) public function getSmallIntTypeDeclarationSQL(array $field)
{ {
return 'SMALLINT' . $this->_getCommonIntegerTypeDeclarationSql($field); return 'SMALLINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
} }
public function getVarcharTypeDeclarationSql(array $field) public function getVarcharTypeDeclarationSQL(array $field)
{ {
if ( ! isset($field['length'])) { if ( ! isset($field['length'])) {
if (array_key_exists('default', $field)) { if (array_key_exists('default', $field)) {
...@@ -314,7 +314,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -314,7 +314,7 @@ class MsSqlPlatform extends AbstractPlatform
} }
/** @override */ /** @override */
public function getClobTypeDeclarationSql(array $field) public function getClobTypeDeclarationSQL(array $field)
{ {
return 'TEXT'; return 'TEXT';
} }
...@@ -322,7 +322,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -322,7 +322,7 @@ class MsSqlPlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
protected function _getCommonIntegerTypeDeclarationSql(array $columnDef) protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
{ {
$autoinc = ''; $autoinc = '';
if ( ! empty($columnDef['autoincrement'])) { if ( ! empty($columnDef['autoincrement'])) {
...@@ -336,7 +336,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -336,7 +336,7 @@ class MsSqlPlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
public function getDateTimeTypeDeclarationSql(array $fieldDeclaration) public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
{ {
return 'CHAR(' . strlen('YYYY-MM-DD HH:MM:SS') . ')'; return 'CHAR(' . strlen('YYYY-MM-DD HH:MM:SS') . ')';
} }
...@@ -344,7 +344,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -344,7 +344,7 @@ class MsSqlPlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
public function getDateTypeDeclarationSql(array $fieldDeclaration) public function getDateTypeDeclarationSQL(array $fieldDeclaration)
{ {
return 'CHAR(' . strlen('YYYY-MM-DD') . ')'; return 'CHAR(' . strlen('YYYY-MM-DD') . ')';
} }
...@@ -352,7 +352,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -352,7 +352,7 @@ class MsSqlPlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
public function getTimeTypeDeclarationSql(array $fieldDeclaration) public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
{ {
return 'CHAR(' . strlen('HH:MM:SS') . ')'; return 'CHAR(' . strlen('HH:MM:SS') . ')';
} }
...@@ -360,7 +360,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -360,7 +360,7 @@ class MsSqlPlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
public function getBooleanTypeDeclarationSql(array $field) public function getBooleanTypeDeclarationSQL(array $field)
{ {
return 'BIT'; return 'BIT';
} }
...@@ -470,7 +470,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -470,7 +470,7 @@ class MsSqlPlatform extends AbstractPlatform
* @param string $identifierColumnName * @param string $identifierColumnName
* @return string $sql * @return string $sql
*/ */
public function getEmptyIdentityInsertSql($quotedTableName, $quotedIdentifierColumnName) public function getEmptyIdentityInsertSQL($quotedTableName, $quotedIdentifierColumnName)
{ {
return 'INSERT INTO ' . $quotedTableName . ' DEFAULT VALUES'; return 'INSERT INTO ' . $quotedTableName . ' DEFAULT VALUES';
} }
...@@ -478,7 +478,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -478,7 +478,7 @@ class MsSqlPlatform extends AbstractPlatform
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function getTruncateTableSql($tableName, $cascade = false) public function getTruncateTableSQL($tableName, $cascade = false)
{ {
return 'TRUNCATE TABLE '.$tableName; return 'TRUNCATE TABLE '.$tableName;
} }
......
...@@ -126,7 +126,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -126,7 +126,7 @@ class SqlitePlatform extends AbstractPlatform
} }
} }
protected function _getTransactionIsolationLevelSql($level) protected function _getTransactionIsolationLevelSQL($level)
{ {
switch ($level) { switch ($level) {
case \Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED: case \Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED:
...@@ -136,13 +136,13 @@ class SqlitePlatform extends AbstractPlatform ...@@ -136,13 +136,13 @@ class SqlitePlatform extends AbstractPlatform
case \Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE: case \Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE:
return 1; return 1;
default: default:
return parent::_getTransactionIsolationLevelSql($level); return parent::_getTransactionIsolationLevelSQL($level);
} }
} }
public function getSetTransactionIsolationSql($level) public function getSetTransactionIsolationSQL($level)
{ {
return 'PRAGMA read_uncommitted = ' . $this->_getTransactionIsolationLevelSql($level); return 'PRAGMA read_uncommitted = ' . $this->_getTransactionIsolationLevelSQL($level);
} }
/** /**
...@@ -156,7 +156,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -156,7 +156,7 @@ class SqlitePlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
public function getBooleanTypeDeclarationSql(array $field) public function getBooleanTypeDeclarationSQL(array $field)
{ {
return 'BOOLEAN'; return 'BOOLEAN';
} }
...@@ -164,17 +164,17 @@ class SqlitePlatform extends AbstractPlatform ...@@ -164,17 +164,17 @@ class SqlitePlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
public function getIntegerTypeDeclarationSql(array $field) public function getIntegerTypeDeclarationSQL(array $field)
{ {
return $this->_getCommonIntegerTypeDeclarationSql($field); return $this->_getCommonIntegerTypeDeclarationSQL($field);
} }
/** /**
* @override * @override
*/ */
public function getBigIntTypeDeclarationSql(array $field) public function getBigIntTypeDeclarationSQL(array $field)
{ {
return $this->_getCommonIntegerTypeDeclarationSql($field); return $this->_getCommonIntegerTypeDeclarationSQL($field);
} }
/** /**
...@@ -182,15 +182,15 @@ class SqlitePlatform extends AbstractPlatform ...@@ -182,15 +182,15 @@ class SqlitePlatform extends AbstractPlatform
*/ */
public function getTinyIntTypeDeclarationSql(array $field) public function getTinyIntTypeDeclarationSql(array $field)
{ {
return $this->_getCommonIntegerTypeDeclarationSql($field); return $this->_getCommonIntegerTypeDeclarationSQL($field);
} }
/** /**
* @override * @override
*/ */
public function getSmallIntTypeDeclarationSql(array $field) public function getSmallIntTypeDeclarationSQL(array $field)
{ {
return $this->_getCommonIntegerTypeDeclarationSql($field); return $this->_getCommonIntegerTypeDeclarationSQL($field);
} }
/** /**
...@@ -198,13 +198,13 @@ class SqlitePlatform extends AbstractPlatform ...@@ -198,13 +198,13 @@ class SqlitePlatform extends AbstractPlatform
*/ */
public function getMediumIntTypeDeclarationSql(array $field) public function getMediumIntTypeDeclarationSql(array $field)
{ {
return $this->_getCommonIntegerTypeDeclarationSql($field); return $this->_getCommonIntegerTypeDeclarationSQL($field);
} }
/** /**
* @override * @override
*/ */
public function getDateTimeTypeDeclarationSql(array $fieldDeclaration) public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
{ {
return 'DATETIME'; return 'DATETIME';
} }
...@@ -212,7 +212,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -212,7 +212,7 @@ class SqlitePlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
public function getDateTypeDeclarationSql(array $fieldDeclaration) public function getDateTypeDeclarationSQL(array $fieldDeclaration)
{ {
return 'DATE'; return 'DATE';
} }
...@@ -220,7 +220,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -220,7 +220,7 @@ class SqlitePlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
public function getTimeTypeDeclarationSql(array $fieldDeclaration) public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
{ {
return 'TIME'; return 'TIME';
} }
...@@ -228,7 +228,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -228,7 +228,7 @@ class SqlitePlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
protected function _getCommonIntegerTypeDeclarationSql(array $columnDef) protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
{ {
$autoinc = ! empty($columnDef['autoincrement']) ? ' AUTOINCREMENT' : ''; $autoinc = ! empty($columnDef['autoincrement']) ? ' AUTOINCREMENT' : '';
$pk = ! empty($columnDef['primary']) && ! empty($autoinc) ? ' PRIMARY KEY' : ''; $pk = ! empty($columnDef['primary']) && ! empty($autoinc) ? ' PRIMARY KEY' : '';
...@@ -265,9 +265,9 @@ class SqlitePlatform extends AbstractPlatform ...@@ -265,9 +265,9 @@ class SqlitePlatform extends AbstractPlatform
* @return void * @return void
* @override * @override
*/ */
protected function _getCreateTableSql($name, array $columns, array $options = array()) protected function _getCreateTableSQL($name, array $columns, array $options = array())
{ {
$queryFields = $this->getColumnDeclarationListSql($columns); $queryFields = $this->getColumnDeclarationListSQL($columns);
$autoinc = false; $autoinc = false;
foreach($columns as $field) { foreach($columns as $field) {
...@@ -287,12 +287,12 @@ class SqlitePlatform extends AbstractPlatform ...@@ -287,12 +287,12 @@ class SqlitePlatform extends AbstractPlatform
if (isset($options['indexes']) && ! empty($options['indexes'])) { if (isset($options['indexes']) && ! empty($options['indexes'])) {
foreach ($options['indexes'] as $index => $indexDef) { foreach ($options['indexes'] as $index => $indexDef) {
$query[] = $this->getCreateIndexSql($indexDef, $name); $query[] = $this->getCreateIndexSQL($indexDef, $name);
} }
} }
if (isset($options['unique']) && ! empty($options['unique'])) { if (isset($options['unique']) && ! empty($options['unique'])) {
foreach ($options['unique'] as $index => $indexDef) { foreach ($options['unique'] as $index => $indexDef) {
$query[] = $this->getCreateIndexSql($indexDef, $name); $query[] = $this->getCreateIndexSQL($indexDef, $name);
} }
} }
return $query; return $query;
...@@ -301,7 +301,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -301,7 +301,7 @@ class SqlitePlatform extends AbstractPlatform
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getVarcharTypeDeclarationSql(array $field) public function getVarcharTypeDeclarationSQL(array $field)
{ {
if ( ! isset($field['length'])) { if ( ! isset($field['length'])) {
if (array_key_exists('default', $field)) { if (array_key_exists('default', $field)) {
...@@ -317,44 +317,44 @@ class SqlitePlatform extends AbstractPlatform ...@@ -317,44 +317,44 @@ class SqlitePlatform extends AbstractPlatform
: ($length ? 'VARCHAR(' . $length . ')' : 'TEXT'); : ($length ? 'VARCHAR(' . $length . ')' : 'TEXT');
} }
public function getClobTypeDeclarationSql(array $field) public function getClobTypeDeclarationSQL(array $field)
{ {
return 'CLOB'; return 'CLOB';
} }
public function getListTableConstraintsSql($table) public function getListTableConstraintsSQL($table)
{ {
return "SELECT sql FROM sqlite_master WHERE type='index' AND tbl_name = '$table' AND sql NOT NULL ORDER BY name"; return "SELECT sql FROM sqlite_master WHERE type='index' AND tbl_name = '$table' AND sql NOT NULL ORDER BY name";
} }
public function getListTableColumnsSql($table) public function getListTableColumnsSQL($table)
{ {
return "PRAGMA table_info($table)"; return "PRAGMA table_info($table)";
} }
public function getListTableIndexesSql($table) public function getListTableIndexesSQL($table)
{ {
return "PRAGMA index_list($table)"; return "PRAGMA index_list($table)";
} }
public function getListTablesSql() public function getListTablesSQL()
{ {
return "SELECT name FROM sqlite_master WHERE type = 'table' AND name != 'sqlite_sequence' " return "SELECT name FROM sqlite_master WHERE type = 'table' AND name != 'sqlite_sequence' "
. "UNION ALL SELECT name FROM sqlite_temp_master " . "UNION ALL SELECT name FROM sqlite_temp_master "
. "WHERE type = 'table' ORDER BY name"; . "WHERE type = 'table' ORDER BY name";
} }
public function getListViewsSql($database) public function getListViewsSQL($database)
{ {
return "SELECT name, sql FROM sqlite_master WHERE type='view' AND sql NOT NULL"; return "SELECT name, sql FROM sqlite_master WHERE type='view' AND sql NOT NULL";
} }
public function getCreateViewSql($name, $sql) public function getCreateViewSQL($name, $sql)
{ {
return 'CREATE VIEW ' . $name . ' AS ' . $sql; return 'CREATE VIEW ' . $name . ' AS ' . $sql;
} }
public function getDropViewSql($name) public function getDropViewSQL($name)
{ {
return 'DROP VIEW '. $name; return 'DROP VIEW '. $name;
} }
...@@ -390,7 +390,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -390,7 +390,7 @@ class SqlitePlatform extends AbstractPlatform
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function getTruncateTableSql($tableName, $cascade = false) public function getTruncateTableSQL($tableName, $cascade = false)
{ {
return 'DELETE FROM '.$tableName; return 'DELETE FROM '.$tableName;
} }
......
...@@ -108,7 +108,7 @@ abstract class AbstractSchemaManager ...@@ -108,7 +108,7 @@ abstract class AbstractSchemaManager
*/ */
public function listDatabases() public function listDatabases()
{ {
$sql = $this->_platform->getListDatabasesSql(); $sql = $this->_platform->getListDatabasesSQL();
$databases = $this->_conn->fetchAll($sql); $databases = $this->_conn->fetchAll($sql);
...@@ -125,7 +125,7 @@ abstract class AbstractSchemaManager ...@@ -125,7 +125,7 @@ abstract class AbstractSchemaManager
if (is_null($database)) { if (is_null($database)) {
$database = $this->_conn->getDatabase(); $database = $this->_conn->getDatabase();
} }
$sql = $this->_platform->getListSequencesSql($database); $sql = $this->_platform->getListSequencesSQL($database);
$sequences = $this->_conn->fetchAll($sql); $sequences = $this->_conn->fetchAll($sql);
...@@ -147,7 +147,7 @@ abstract class AbstractSchemaManager ...@@ -147,7 +147,7 @@ abstract class AbstractSchemaManager
*/ */
public function listTableColumns($table) public function listTableColumns($table)
{ {
$sql = $this->_platform->getListTableColumnsSql($table); $sql = $this->_platform->getListTableColumnsSQL($table);
$tableColumns = $this->_conn->fetchAll($sql); $tableColumns = $this->_conn->fetchAll($sql);
...@@ -164,7 +164,7 @@ abstract class AbstractSchemaManager ...@@ -164,7 +164,7 @@ abstract class AbstractSchemaManager
*/ */
public function listTableIndexes($table) public function listTableIndexes($table)
{ {
$sql = $this->_platform->getListTableIndexesSql($table); $sql = $this->_platform->getListTableIndexesSQL($table);
$tableIndexes = $this->_conn->fetchAll($sql); $tableIndexes = $this->_conn->fetchAll($sql);
...@@ -178,7 +178,7 @@ abstract class AbstractSchemaManager ...@@ -178,7 +178,7 @@ abstract class AbstractSchemaManager
*/ */
public function listTableNames() public function listTableNames()
{ {
$sql = $this->_platform->getListTablesSql(); $sql = $this->_platform->getListTablesSQL();
$tables = $this->_conn->fetchAll($sql); $tables = $this->_conn->fetchAll($sql);
...@@ -233,7 +233,7 @@ abstract class AbstractSchemaManager ...@@ -233,7 +233,7 @@ abstract class AbstractSchemaManager
public function listViews() public function listViews()
{ {
$database = $this->_conn->getDatabase(); $database = $this->_conn->getDatabase();
$sql = $this->_platform->getListViewsSql($database); $sql = $this->_platform->getListViewsSQL($database);
$views = $this->_conn->fetchAll($sql); $views = $this->_conn->fetchAll($sql);
return $this->_getPortableViewsList($views); return $this->_getPortableViewsList($views);
...@@ -250,7 +250,7 @@ abstract class AbstractSchemaManager ...@@ -250,7 +250,7 @@ abstract class AbstractSchemaManager
if (is_null($database)) { if (is_null($database)) {
$database = $this->_conn->getDatabase(); $database = $this->_conn->getDatabase();
} }
$sql = $this->_platform->getListTableForeignKeysSql($table, $database); $sql = $this->_platform->getListTableForeignKeysSQL($table, $database);
$tableForeignKeys = $this->_conn->fetchAll($sql); $tableForeignKeys = $this->_conn->fetchAll($sql);
return $this->_getPortableTableForeignKeysList($tableForeignKeys); return $this->_getPortableTableForeignKeysList($tableForeignKeys);
...@@ -267,7 +267,7 @@ abstract class AbstractSchemaManager ...@@ -267,7 +267,7 @@ abstract class AbstractSchemaManager
*/ */
public function dropDatabase($database) public function dropDatabase($database)
{ {
$this->_execSql($this->_platform->getDropDatabaseSql($database)); $this->_execSql($this->_platform->getDropDatabaseSQL($database));
} }
/** /**
...@@ -277,7 +277,7 @@ abstract class AbstractSchemaManager ...@@ -277,7 +277,7 @@ abstract class AbstractSchemaManager
*/ */
public function dropTable($table) public function dropTable($table)
{ {
$this->_execSql($this->_platform->getDropTableSql($table)); $this->_execSql($this->_platform->getDropTableSQL($table));
} }
/** /**
...@@ -292,7 +292,7 @@ abstract class AbstractSchemaManager ...@@ -292,7 +292,7 @@ abstract class AbstractSchemaManager
$index = $index->getName(); $index = $index->getName();
} }
$this->_execSql($this->_platform->getDropIndexSql($index, $table)); $this->_execSql($this->_platform->getDropIndexSQL($index, $table));
} }
/** /**
...@@ -303,7 +303,7 @@ abstract class AbstractSchemaManager ...@@ -303,7 +303,7 @@ abstract class AbstractSchemaManager
*/ */
public function dropConstraint(Constraint $constraint, $table) public function dropConstraint(Constraint $constraint, $table)
{ {
$this->_execSql($this->_platform->getDropConstraintSql($constraint, $table)); $this->_execSql($this->_platform->getDropConstraintSQL($constraint, $table));
} }
/** /**
...@@ -315,7 +315,7 @@ abstract class AbstractSchemaManager ...@@ -315,7 +315,7 @@ abstract class AbstractSchemaManager
*/ */
public function dropForeignKey($foreignKey, $table) public function dropForeignKey($foreignKey, $table)
{ {
$this->_execSql($this->_platform->getDropForeignKeySql($foreignKey, $table)); $this->_execSql($this->_platform->getDropForeignKeySQL($foreignKey, $table));
} }
/** /**
...@@ -325,7 +325,7 @@ abstract class AbstractSchemaManager ...@@ -325,7 +325,7 @@ abstract class AbstractSchemaManager
*/ */
public function dropSequence($name) public function dropSequence($name)
{ {
$this->_execSql($this->_platform->getDropSequenceSql($name)); $this->_execSql($this->_platform->getDropSequenceSQL($name));
} }
/** /**
...@@ -336,7 +336,7 @@ abstract class AbstractSchemaManager ...@@ -336,7 +336,7 @@ abstract class AbstractSchemaManager
*/ */
public function dropView($name) public function dropView($name)
{ {
$this->_execSql($this->_platform->getDropViewSql($name)); $this->_execSql($this->_platform->getDropViewSQL($name));
} }
/* create*() Methods */ /* create*() Methods */
...@@ -348,7 +348,7 @@ abstract class AbstractSchemaManager ...@@ -348,7 +348,7 @@ abstract class AbstractSchemaManager
*/ */
public function createDatabase($database) public function createDatabase($database)
{ {
$this->_execSql($this->_platform->getCreateDatabaseSql($database)); $this->_execSql($this->_platform->getCreateDatabaseSQL($database));
} }
/** /**
...@@ -360,7 +360,7 @@ abstract class AbstractSchemaManager ...@@ -360,7 +360,7 @@ abstract class AbstractSchemaManager
public function createTable(Table $table) public function createTable(Table $table)
{ {
$createFlags = AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS; $createFlags = AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS;
$this->_execSql($this->_platform->getCreateTableSql($table, $createFlags)); $this->_execSql($this->_platform->getCreateTableSQL($table, $createFlags));
} }
/** /**
...@@ -371,7 +371,7 @@ abstract class AbstractSchemaManager ...@@ -371,7 +371,7 @@ abstract class AbstractSchemaManager
*/ */
public function createSequence($sequence) public function createSequence($sequence)
{ {
$this->_execSql($this->_platform->getCreateSequenceSql($sequence)); $this->_execSql($this->_platform->getCreateSequenceSQL($sequence));
} }
/** /**
...@@ -382,7 +382,7 @@ abstract class AbstractSchemaManager ...@@ -382,7 +382,7 @@ abstract class AbstractSchemaManager
*/ */
public function createConstraint(Constraint $constraint, $table) public function createConstraint(Constraint $constraint, $table)
{ {
$this->_execSql($this->_platform->getCreateConstraintSql($constraint, $table)); $this->_execSql($this->_platform->getCreateConstraintSQL($constraint, $table));
} }
/** /**
...@@ -393,7 +393,7 @@ abstract class AbstractSchemaManager ...@@ -393,7 +393,7 @@ abstract class AbstractSchemaManager
*/ */
public function createIndex(Index $index, $table) public function createIndex(Index $index, $table)
{ {
$this->_execSql($this->_platform->getCreateIndexSql($index, $table)); $this->_execSql($this->_platform->getCreateIndexSQL($index, $table));
} }
/** /**
...@@ -404,7 +404,7 @@ abstract class AbstractSchemaManager ...@@ -404,7 +404,7 @@ abstract class AbstractSchemaManager
*/ */
public function createForeignKey(ForeignKeyConstraint $foreignKey, $table) public function createForeignKey(ForeignKeyConstraint $foreignKey, $table)
{ {
$this->_execSql($this->_platform->getCreateForeignKeySql($foreignKey, $table)); $this->_execSql($this->_platform->getCreateForeignKeySQL($foreignKey, $table));
} }
/** /**
...@@ -414,7 +414,7 @@ abstract class AbstractSchemaManager ...@@ -414,7 +414,7 @@ abstract class AbstractSchemaManager
*/ */
public function createView(View $view) public function createView(View $view)
{ {
$this->_execSql($this->_platform->getCreateViewSql($view->getName(), $view->getSql())); $this->_execSql($this->_platform->getCreateViewSQL($view->getName(), $view->getSql()));
} }
/* dropAndCreate*() Methods */ /* dropAndCreate*() Methods */
...@@ -511,7 +511,7 @@ abstract class AbstractSchemaManager ...@@ -511,7 +511,7 @@ abstract class AbstractSchemaManager
*/ */
public function alterTable(TableDiff $tableDiff) public function alterTable(TableDiff $tableDiff)
{ {
$queries = $this->_platform->getAlterTableSql($tableDiff); $queries = $this->_platform->getAlterTableSQL($tableDiff);
if (is_array($queries) && count($queries)) { if (is_array($queries) && count($queries)) {
foreach ($queries AS $ddlQuery) { foreach ($queries AS $ddlQuery) {
$this->_execSql($ddlQuery); $this->_execSql($ddlQuery);
......
...@@ -160,7 +160,7 @@ class MsSqlSchemaManager extends AbstractSchemaManager ...@@ -160,7 +160,7 @@ class MsSqlSchemaManager extends AbstractSchemaManager
case 'rename': case 'rename':
case 'change': case 'change':
default: default:
throw \Doctrine\Common\DoctrineException::alterTableChangeNotSupported($changeName); throw SchemaException::alterTableChangeNotSupported($changeName);
} }
} }
......
...@@ -128,42 +128,42 @@ class SchemaDiff ...@@ -128,42 +128,42 @@ class SchemaDiff
if ($platform->supportsForeignKeyConstraints() && $saveMode == false) { if ($platform->supportsForeignKeyConstraints() && $saveMode == false) {
foreach ($this->orphanedForeignKeys AS $orphanedForeignKey) { foreach ($this->orphanedForeignKeys AS $orphanedForeignKey) {
$sql[] = $platform->getDropForeignKeySql($orphanedForeignKey, $orphanedForeignKey->getLocalTableName()); $sql[] = $platform->getDropForeignKeySQL($orphanedForeignKey, $orphanedForeignKey->getLocalTableName());
} }
} }
if ($platform->supportsSequences() == true) { if ($platform->supportsSequences() == true) {
foreach ($this->changedSequences AS $sequence) { foreach ($this->changedSequences AS $sequence) {
$sql[] = $platform->getDropSequenceSql($sequence); $sql[] = $platform->getDropSequenceSQL($sequence);
$sql[] = $platform->getCreateSequenceSql($sequence); $sql[] = $platform->getCreateSequenceSQL($sequence);
} }
if ($saveMode === false) { if ($saveMode === false) {
foreach ($this->removedSequences AS $sequence) { foreach ($this->removedSequences AS $sequence) {
$sql[] = $platform->getDropSequenceSql($sequence); $sql[] = $platform->getDropSequenceSQL($sequence);
} }
} }
foreach ($this->newSequences AS $sequence) { foreach ($this->newSequences AS $sequence) {
$sql[] = $platform->getCreateSequenceSql($sequence); $sql[] = $platform->getCreateSequenceSQL($sequence);
} }
} }
foreach ($this->newTables AS $table) { foreach ($this->newTables AS $table) {
$sql = array_merge( $sql = array_merge(
$sql, $sql,
$platform->getCreateTableSql($table, AbstractPlatform::CREATE_FOREIGNKEYS|AbstractPlatform::CREATE_INDEXES) $platform->getCreateTableSQL($table, AbstractPlatform::CREATE_FOREIGNKEYS|AbstractPlatform::CREATE_INDEXES)
); );
} }
if ($saveMode === false) { if ($saveMode === false) {
foreach ($this->removedTables AS $table) { foreach ($this->removedTables AS $table) {
$sql[] = $platform->getDropTableSql($table); $sql[] = $platform->getDropTableSQL($table);
} }
} }
foreach ($this->changedTables AS $tableDiff) { foreach ($this->changedTables AS $tableDiff) {
$sql = array_merge($sql, $platform->getAlterTableSql($tableDiff)); $sql = array_merge($sql, $platform->getAlterTableSQL($tableDiff));
} }
return $sql; return $sql;
......
...@@ -119,4 +119,8 @@ class SchemaException extends \Doctrine\DBAL\DBALException ...@@ -119,4 +119,8 @@ class SchemaException extends \Doctrine\DBAL\DBALException
"unnamed." "unnamed."
); );
} }
static public function alterTableChangeNotSupported($changeName) {
return new self ("Alter table change not supported, given '$changeName'");
}
} }
\ No newline at end of file
...@@ -77,7 +77,7 @@ class CreateSchemaSqlCollector implements Visitor ...@@ -77,7 +77,7 @@ class CreateSchemaSqlCollector implements Visitor
public function acceptTable(Table $table) public function acceptTable(Table $table)
{ {
$this->_createTableQueries = array_merge($this->_createTableQueries, $this->_createTableQueries = array_merge($this->_createTableQueries,
$this->_platform->getCreateTableSql($table) $this->_platform->getCreateTableSQL($table)
); );
} }
...@@ -95,7 +95,7 @@ class CreateSchemaSqlCollector implements Visitor ...@@ -95,7 +95,7 @@ class CreateSchemaSqlCollector implements Visitor
// Append the foreign key constraints SQL // Append the foreign key constraints SQL
if ($this->_platform->supportsForeignKeyConstraints()) { if ($this->_platform->supportsForeignKeyConstraints()) {
$this->_createFkConstraintQueries = array_merge($this->_createFkConstraintQueries, $this->_createFkConstraintQueries = array_merge($this->_createFkConstraintQueries,
(array) $this->_platform->getCreateForeignKeySql($fkConstraint, $localTable->getName()) (array) $this->_platform->getCreateForeignKeySQL($fkConstraint, $localTable->getName())
); );
} }
} }
...@@ -115,7 +115,7 @@ class CreateSchemaSqlCollector implements Visitor ...@@ -115,7 +115,7 @@ class CreateSchemaSqlCollector implements Visitor
public function acceptSequence(Sequence $sequence) public function acceptSequence(Sequence $sequence)
{ {
$this->_createSequenceQueries = array_merge( $this->_createSequenceQueries = array_merge(
$this->_createSequenceQueries, (array)$this->_platform->getCreateSequenceSql($sequence) $this->_createSequenceQueries, (array)$this->_platform->getCreateSequenceSQL($sequence)
); );
} }
......
...@@ -83,7 +83,7 @@ class DropSchemaSqlCollector implements Visitor ...@@ -83,7 +83,7 @@ class DropSchemaSqlCollector implements Visitor
*/ */
public function acceptTable(Table $table) public function acceptTable(Table $table)
{ {
$this->_tables[] = $this->_platform->getDropTableSql($table->getName()); $this->_tables[] = $this->_platform->getDropTableSQL($table->getName());
} }
/** /**
...@@ -104,7 +104,7 @@ class DropSchemaSqlCollector implements Visitor ...@@ -104,7 +104,7 @@ class DropSchemaSqlCollector implements Visitor
throw SchemaException::namedForeignKeyRequired($localTable, $fkConstraint); throw SchemaException::namedForeignKeyRequired($localTable, $fkConstraint);
} }
$this->_constraints[] = $this->_platform->getDropForeignKeySql($fkConstraint->getName(), $localTable->getName()); $this->_constraints[] = $this->_platform->getDropForeignKeySQL($fkConstraint->getName(), $localTable->getName());
} }
/** /**
...@@ -121,7 +121,7 @@ class DropSchemaSqlCollector implements Visitor ...@@ -121,7 +121,7 @@ class DropSchemaSqlCollector implements Visitor
*/ */
public function acceptSequence(Sequence $sequence) public function acceptSequence(Sequence $sequence)
{ {
$this->_sequences[] = $this->_platform->getDropSequenceSql($sequence->getName()); $this->_sequences[] = $this->_platform->getDropSequenceSQL($sequence->getName());
} }
/** /**
......
...@@ -11,7 +11,7 @@ class ArrayType extends Type ...@@ -11,7 +11,7 @@ class ArrayType extends Type
{ {
public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{ {
return $platform->getClobTypeDeclarationSql($fieldDeclaration); return $platform->getClobTypeDeclarationSQL($fieldDeclaration);
} }
public function convertToDatabaseValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function convertToDatabaseValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
......
...@@ -17,7 +17,7 @@ class BigIntType extends Type ...@@ -17,7 +17,7 @@ class BigIntType extends Type
public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{ {
return $platform->getBigIntTypeDeclarationSql($fieldDeclaration); return $platform->getBigIntTypeDeclarationSQL($fieldDeclaration);
} }
public function getTypeCode() public function getTypeCode()
......
...@@ -13,7 +13,7 @@ class BooleanType extends Type ...@@ -13,7 +13,7 @@ class BooleanType extends Type
{ {
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{ {
return $platform->getBooleanTypeDeclarationSql($fieldDeclaration); return $platform->getBooleanTypeDeclarationSQL($fieldDeclaration);
} }
public function convertToDatabaseValue($value, AbstractPlatform $platform) public function convertToDatabaseValue($value, AbstractPlatform $platform)
......
...@@ -18,7 +18,7 @@ class DateTimeType extends Type ...@@ -18,7 +18,7 @@ class DateTimeType extends Type
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{ {
return $platform->getDateTimeTypeDeclarationSql($fieldDeclaration); return $platform->getDateTimeTypeDeclarationSQL($fieldDeclaration);
} }
public function convertToDatabaseValue($value, AbstractPlatform $platform) public function convertToDatabaseValue($value, AbstractPlatform $platform)
......
...@@ -18,7 +18,7 @@ class DateType extends Type ...@@ -18,7 +18,7 @@ class DateType extends Type
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{ {
return $platform->getDateTypeDeclarationSql($fieldDeclaration); return $platform->getDateTypeDeclarationSQL($fieldDeclaration);
} }
public function convertToDatabaseValue($value, AbstractPlatform $platform) public function convertToDatabaseValue($value, AbstractPlatform $platform)
......
...@@ -16,7 +16,7 @@ class DecimalType extends Type ...@@ -16,7 +16,7 @@ class DecimalType extends Type
public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{ {
return $platform->getDecimalTypeDeclarationSql($fieldDeclaration); return $platform->getDecimalTypeDeclarationSQL($fieldDeclaration);
} }
public function convertToPHPValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function convertToPHPValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
......
...@@ -17,7 +17,7 @@ class IntegerType extends Type ...@@ -17,7 +17,7 @@ class IntegerType extends Type
public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{ {
return $platform->getIntegerTypeDeclarationSql($fieldDeclaration); return $platform->getIntegerTypeDeclarationSQL($fieldDeclaration);
} }
public function convertToPHPValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function convertToPHPValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
......
...@@ -11,7 +11,7 @@ class ObjectType extends Type ...@@ -11,7 +11,7 @@ class ObjectType extends Type
{ {
public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{ {
return $platform->getClobTypeDeclarationSql($fieldDeclaration); return $platform->getClobTypeDeclarationSQL($fieldDeclaration);
} }
public function convertToDatabaseValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function convertToDatabaseValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
......
...@@ -16,7 +16,7 @@ class SmallIntType extends Type ...@@ -16,7 +16,7 @@ class SmallIntType extends Type
public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{ {
return $platform->getSmallIntTypeDeclarationSql($fieldDeclaration); return $platform->getSmallIntTypeDeclarationSQL($fieldDeclaration);
} }
public function convertToPHPValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function convertToPHPValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
......
...@@ -12,7 +12,7 @@ class StringType extends Type ...@@ -12,7 +12,7 @@ class StringType extends Type
/** @override */ /** @override */
public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{ {
return $platform->getVarcharTypeDeclarationSql($fieldDeclaration); return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
} }
/** @override */ /** @override */
......
...@@ -12,7 +12,7 @@ class TextType extends Type ...@@ -12,7 +12,7 @@ class TextType extends Type
/** @override */ /** @override */
public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{ {
return $platform->getClobTypeDeclarationSql($fieldDeclaration); return $platform->getClobTypeDeclarationSQL($fieldDeclaration);
} }
public function getName() public function getName()
......
...@@ -21,7 +21,7 @@ class TimeType extends Type ...@@ -21,7 +21,7 @@ class TimeType extends Type
*/ */
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{ {
return $platform->getTimeTypeDeclarationSql($fieldDeclaration); return $platform->getTimeTypeDeclarationSQL($fieldDeclaration);
} }
/** /**
......
...@@ -2,9 +2,8 @@ ...@@ -2,9 +2,8 @@
namespace Doctrine\DBAL\Types; namespace Doctrine\DBAL\Types;
use Doctrine\Common\DoctrineException; use Doctrine\DBAL\Platforms\AbstractPlatform,
use Doctrine\DBAL\Platforms\AbstractPlatform; Doctrine\DBAL\DBALException;
use Doctrine\DBAL\DBALException;
/** /**
* The base class for so-called Doctrine mapping types. * The base class for so-called Doctrine mapping types.
......
...@@ -227,7 +227,7 @@ abstract class AbstractQuery ...@@ -227,7 +227,7 @@ abstract class AbstractQuery
public function setResultCacheDriver($resultCacheDriver = null) public function setResultCacheDriver($resultCacheDriver = null)
{ {
if ($resultCacheDriver !== null && ! ($resultCacheDriver instanceof \Doctrine\Common\Cache\Cache)) { if ($resultCacheDriver !== null && ! ($resultCacheDriver instanceof \Doctrine\Common\Cache\Cache)) {
throw DoctrineException::invalidResultCacheObject($resultCacheDriver); throw ORMException::invalidResultCacheDriver();
} }
$this->_resultCacheDriver = $resultCacheDriver; $this->_resultCacheDriver = $resultCacheDriver;
if ($resultCacheDriver) { if ($resultCacheDriver) {
......
...@@ -304,7 +304,7 @@ class Configuration extends \Doctrine\DBAL\Configuration ...@@ -304,7 +304,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
* Ensures that this Configuration instance contains settings that are * Ensures that this Configuration instance contains settings that are
* suitable for a production environment. * suitable for a production environment.
* *
* @throws DoctrineException If a configuration setting has a value that is not * @throws ORMException If a configuration setting has a value that is not
* suitable for a production environment. * suitable for a production environment.
*/ */
public function ensureProductionSettings() public function ensureProductionSettings()
......
...@@ -61,7 +61,7 @@ class SequenceGenerator extends AbstractIdGenerator implements \Serializable ...@@ -61,7 +61,7 @@ class SequenceGenerator extends AbstractIdGenerator implements \Serializable
if ($this->_maxValue === null || $this->_nextValue == $this->_maxValue) { if ($this->_maxValue === null || $this->_nextValue == $this->_maxValue) {
// Allocate new values // Allocate new values
$conn = $em->getConnection(); $conn = $em->getConnection();
$sql = $conn->getDatabasePlatform()->getSequenceNextValSql($this->_sequenceName); $sql = $conn->getDatabasePlatform()->getSequenceNextValSQL($this->_sequenceName);
$this->_nextValue = $conn->fetchColumn($sql); $this->_nextValue = $conn->fetchColumn($sql);
$this->_maxValue = $this->_nextValue + $this->_allocationSize; $this->_maxValue = $this->_nextValue + $this->_allocationSize;
} }
......
...@@ -14,6 +14,6 @@ class TableGenerator extends AbstractIdGenerator ...@@ -14,6 +14,6 @@ class TableGenerator extends AbstractIdGenerator
{ {
public function generate(EntityManager $em, $entity) public function generate(EntityManager $em, $entity)
{ {
throw \Doctrine\Common\DoctrineException::notImplemented(__CLASS__ . '::' . __FUNCTION__); throw new \BadMethodCallException(__CLASS__."::".__FUNCTION__." not implemented.");
} }
} }
\ No newline at end of file
...@@ -82,8 +82,7 @@ class CommitOrderCalculator ...@@ -82,8 +82,7 @@ class CommitOrderCalculator
$sorted = array_reverse($this->_sorted); $sorted = array_reverse($this->_sorted);
$this->_sorted = $this->_sorted = $this->_nodeStates = array();
$this->_nodeStates = array();
return $sorted; return $sorted;
} }
......
...@@ -177,15 +177,6 @@ class ClassMetadata extends ClassMetadataInfo ...@@ -177,15 +177,6 @@ class ClassMetadata extends ClassMetadataInfo
} }
} }
public function getColumnValues($entity, array $columns)
{
$values = array();
foreach ($columns as $column) {
$values[] = $this->reflFields[$this->fieldNames[$column]]->getValue($entity);
}
return $values;
}
/** /**
* Populates the entity identifier of an entity. * Populates the entity identifier of an entity.
* *
...@@ -288,20 +279,6 @@ class ClassMetadata extends ClassMetadataInfo ...@@ -288,20 +279,6 @@ class ClassMetadata extends ClassMetadataInfo
$this->primaryTable['name']; $this->primaryTable['name'];
} }
/**
* Gets the (possibly quoted) name of the discriminator column for safe use
* in an SQL statement.
*
* @param AbstractPlatform $platform
* @return string
*/
public function getQuotedDiscriminatorColumnName($platform)
{
return isset($this->discriminatorColumn['quoted']) ?
$platform->quoteIdentifier($this->discriminatorColumn['name']) :
$this->discriminatorColumn['name'];
}
/** /**
* Creates a string representation of this instance. * Creates a string representation of this instance.
* *
......
...@@ -130,12 +130,13 @@ class ClassMetadataFactory ...@@ -130,12 +130,13 @@ class ClassMetadataFactory
if ( ! isset($this->_loadedMetadata[$className])) { if ( ! isset($this->_loadedMetadata[$className])) {
$realClassName = $className; $realClassName = $className;
// Check for namespace alias
if (strpos($className, ':') !== false) { if (strpos($className, ':') !== false) {
list($namespaceAlias, $simpleClassName) = explode(':', $className); list($namespaceAlias, $simpleClassName) = explode(':', $className);
$realClassName = $this->_em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName; $realClassName = $this->_em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
if (isset($this->_loadedMetadata[$realClassName])) { if (isset($this->_loadedMetadata[$realClassName])) {
// We do not have the alias reference, include it // We do not have the alias name in the map, include it
$this->_loadedMetadata[$className] = $this->_loadedMetadata[$realClassName]; $this->_loadedMetadata[$className] = $this->_loadedMetadata[$realClassName];
return $this->_loadedMetadata[$realClassName]; return $this->_loadedMetadata[$realClassName];
...@@ -158,9 +159,8 @@ class ClassMetadataFactory ...@@ -158,9 +159,8 @@ class ClassMetadataFactory
$this->_loadMetadata($realClassName); $this->_loadMetadata($realClassName);
} }
// Include the alias of this situation:
// CMS:CmsUser => Doctrine\Tests\ORM\Models\CMS\CmsUser
if ($className != $realClassName) { if ($className != $realClassName) {
// We do not have the alias name in the map, include it
$this->_loadedMetadata[$className] = $this->_loadedMetadata[$realClassName]; $this->_loadedMetadata[$className] = $this->_loadedMetadata[$realClassName];
} }
} }
......
...@@ -66,7 +66,7 @@ class AnnotationDriver implements Driver ...@@ -66,7 +66,7 @@ class AnnotationDriver implements Driver
/** /**
* @param array * @param array
*/ */
protected $_classNames = null; protected $_classNames;
/** /**
* Initializes a new AnnotationDriver that uses the given AnnotationReader for reading * Initializes a new AnnotationDriver that uses the given AnnotationReader for reading
...@@ -433,7 +433,7 @@ class AnnotationDriver implements Driver ...@@ -433,7 +433,7 @@ class AnnotationDriver implements Driver
foreach ((array) $this->_paths as $path) { foreach ((array) $this->_paths as $path) {
if ( ! is_dir($path)) { if ( ! is_dir($path)) {
throw MappingException::annotationDriverRequiresConfiguredDirectoryPath(); throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath();
} }
$iterator = new \RecursiveIteratorIterator( $iterator = new \RecursiveIteratorIterator(
......
...@@ -126,27 +126,19 @@ class ManyToManyMapping extends AssociationMapping ...@@ -126,27 +126,19 @@ class ManyToManyMapping extends AssociationMapping
); );
} }
foreach ($mapping['joinTable']['joinColumns'] as &$joinColumn) { foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) {
if ($joinColumn['name'][0] == '`') {
$joinColumn['name'] = trim($joinColumn['name'], '`');
$joinColumn['quoted'] = true;
}
$this->relationToSourceKeyColumns[$joinColumn['name']] = $joinColumn['referencedColumnName']; $this->relationToSourceKeyColumns[$joinColumn['name']] = $joinColumn['referencedColumnName'];
$this->joinTableColumns[] = $joinColumn['name']; $this->joinTableColumns[] = $joinColumn['name'];
} }
foreach ($mapping['joinTable']['inverseJoinColumns'] as &$inverseJoinColumn) { foreach ($mapping['joinTable']['inverseJoinColumns'] as $inverseJoinColumn) {
if ($inverseJoinColumn['name'][0] == '`') {
$inverseJoinColumn['name'] = trim($inverseJoinColumn['name'], '`');
$inverseJoinColumn['quoted'] = true;
}
$this->relationToTargetKeyColumns[$inverseJoinColumn['name']] = $inverseJoinColumn['referencedColumnName']; $this->relationToTargetKeyColumns[$inverseJoinColumn['name']] = $inverseJoinColumn['referencedColumnName'];
$this->joinTableColumns[] = $inverseJoinColumn['name']; $this->joinTableColumns[] = $inverseJoinColumn['name'];
} }
} }
if (isset($mapping['orderBy'])) { if (isset($mapping['orderBy'])) {
if (!is_array($mapping['orderBy'])) { if ( ! is_array($mapping['orderBy'])) {
throw new \InvalidArgumentException("'orderBy' is expected to be an array, not ".gettype($mapping['orderBy'])); throw new \InvalidArgumentException("'orderBy' is expected to be an array, not ".gettype($mapping['orderBy']));
} }
$this->orderBy = $mapping['orderBy']; $this->orderBy = $mapping['orderBy'];
...@@ -212,26 +204,8 @@ class ManyToManyMapping extends AssociationMapping ...@@ -212,26 +204,8 @@ class ManyToManyMapping extends AssociationMapping
$persister->loadManyToManyCollection($this, $joinTableConditions, $targetCollection); $persister->loadManyToManyCollection($this, $joinTableConditions, $targetCollection);
} }
/**
* {@inheritdoc}
*/
public function isManyToMany() public function isManyToMany()
{ {
return true; return true;
} }
/**
* Gets the (possibly quoted) column name of a join column that is safe to use
* in an SQL statement.
*
* @param string $joinColumn
* @param AbstractPlatform $platform
* @return string
*/
public function getQuotedJoinColumnName($joinColumn, $platform)
{
return isset($this->joinTable['joinColumns'][$joinColumn]['quoted']) ?
$platform->quoteIdentifier($joinColumn) :
$joinColumn;
}
} }
...@@ -166,9 +166,9 @@ class MappingException extends \Doctrine\ORM\ORMException ...@@ -166,9 +166,9 @@ class MappingException extends \Doctrine\ORM\ORMException
); );
} }
public static function annotationDriverRequiresConfiguredDirectoryPath() public static function fileMappingDriversRequireConfiguredDirectoryPath()
{ {
return new self('The annotation driver needs to have a directory path'); return new self('File mapping drivers must have a directory path');
} }
/** /**
......
...@@ -54,7 +54,7 @@ class OneToManyMapping extends AssociationMapping ...@@ -54,7 +54,7 @@ class OneToManyMapping extends AssociationMapping
/** /**
* Order this collection by the given SQL snippet. * Order this collection by the given SQL snippet.
*/ */
public $orderBy = null; public $orderBy;
/** /**
* Initializes a new OneToManyMapping. * Initializes a new OneToManyMapping.
......
...@@ -119,11 +119,7 @@ class OneToOneMapping extends AssociationMapping ...@@ -119,11 +119,7 @@ class OneToOneMapping extends AssociationMapping
'referencedColumnName' => 'id' 'referencedColumnName' => 'id'
)); ));
} }
foreach ($mapping['joinColumns'] as &$joinColumn) { foreach ($mapping['joinColumns'] as $joinColumn) {
if ($joinColumn['name'][0] == '`') {
$joinColumn['name'] = trim($joinColumn['name'], '`');
$joinColumn['quoted'] = true;
}
$this->sourceToTargetKeyColumns[$joinColumn['name']] = $joinColumn['referencedColumnName']; $this->sourceToTargetKeyColumns[$joinColumn['name']] = $joinColumn['referencedColumnName'];
$this->joinColumnFieldNames[$joinColumn['name']] = isset($joinColumn['fieldName']) $this->joinColumnFieldNames[$joinColumn['name']] = isset($joinColumn['fieldName'])
? $joinColumn['fieldName'] : $joinColumn['name']; ? $joinColumn['fieldName'] : $joinColumn['name'];
...@@ -195,21 +191,6 @@ class OneToOneMapping extends AssociationMapping ...@@ -195,21 +191,6 @@ class OneToOneMapping extends AssociationMapping
return true; return true;
} }
/**
* Gets the (possibly quoted) column name of a join column that is safe to use
* in an SQL statement.
*
* @param string $joinColumn
* @param AbstractPlatform $platform
* @return string
*/
public function getQuotedJoinColumnName($joinColumn, $platform)
{
return isset($this->joinColumns[$joinColumn]['quoted']) ?
$platform->quoteIdentifier($joinColumn) :
$joinColumn;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
* *
......
...@@ -70,6 +70,14 @@ class ORMException extends \Exception ...@@ -70,6 +70,14 @@ class ORMException extends \Exception
); );
} }
public static function invalidResultCacheDriver() {
return new self("Invalid result cache driver; it must implement \Doctrine\Common\Cache\Cache.");
}
public static function notSupported() {
return new self("This behaviour is (currently) not supported by Doctrine 2");
}
public static function queryCacheNotConfigured() public static function queryCacheNotConfigured()
{ {
return new self('Query Cache is not configured.'); return new self('Query Cache is not configured.');
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
namespace Doctrine\ORM\Persisters; namespace Doctrine\ORM\Persisters;
use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Mapping\ClassMetadata;
/** /**
* Persister for entities that participate in a hierarchy mapped with the * Persister for entities that participate in a hierarchy mapped with the
...@@ -41,36 +41,30 @@ class SingleTablePersister extends StandardEntityPersister ...@@ -41,36 +41,30 @@ class SingleTablePersister extends StandardEntityPersister
parent::_prepareData($entity, $result, $isInsert); parent::_prepareData($entity, $result, $isInsert);
// Populate the discriminator column // Populate the discriminator column
if ($isInsert) { if ($isInsert) {
$discColumn = $this->_class->getQuotedDiscriminatorColumnName($this->_platform); $discColumn = $this->_class->discriminatorColumn['name'];
$result[$this->_class->getQuotedTableName($this->_platform)][$discColumn] = $result[$this->_class->getQuotedTableName($this->_platform)][$discColumn] =
$this->_class->discriminatorValue; $this->_class->discriminatorValue;
} }
} }
/** @override */ /** @override */
protected function _getSelectColumnList() protected function _getSelectColumnListSQL()
{ {
$setResultColumnNames = empty($this->_resultColumnNames); $columnList = parent::_getSelectColumnListSQL();
$columnList = parent::_getSelectColumnList();
// Append discriminator column // Append discriminator column
$columnList .= ', ' . $this->_class->getQuotedDiscriminatorColumnName($this->_platform); $discrColumn = $this->_class->discriminatorColumn['name'];
$columnList .= ", $discrColumn";
$rootClass = $this->_em->getClassMetadata($this->_class->rootEntityName);
$tableAlias = $this->_getSQLTableAlias($rootClass);
$resultColumnName = $this->_platform->getSQLResultCasing($discrColumn);
$this->_resultColumnNames[$resultColumnName] = $discrColumn;
if ($setResultColumnNames) {
$resultColumnName = $this->_platform->getSqlResultCasing($this->_class->discriminatorColumn['name']);
$this->_resultColumnNames[$resultColumnName] = $this->_class->discriminatorColumn['name'];
}
///$tableAlias = $this->_class->getQuotedTableName($this->_platform);
foreach ($this->_class->subClasses as $subClassName) { foreach ($this->_class->subClasses as $subClassName) {
$subClass = $this->_em->getClassMetadata($subClassName); $subClass = $this->_em->getClassMetadata($subClassName);
// Append subclass columns // Append subclass columns
foreach ($subClass->fieldMappings as $fieldName => $mapping) { foreach ($subClass->fieldMappings as $fieldName => $mapping) {
if ( ! isset($mapping['inherited'])) { if ( ! isset($mapping['inherited'])) {
$columnList .= ', ' . $subClass->getQuotedColumnName($fieldName, $this->_platform); $columnList .= ', ' . $this->_getSelectColumnSQL($fieldName, $subClass);
if ($setResultColumnNames) {
$resultColumnName = $this->_platform->getSqlResultCasing($mapping['columnName']);
$this->_resultColumnNames[$resultColumnName] = $mapping['columnName'];
}
} }
} }
...@@ -78,9 +72,10 @@ class SingleTablePersister extends StandardEntityPersister ...@@ -78,9 +72,10 @@ class SingleTablePersister extends StandardEntityPersister
foreach ($subClass->associationMappings as $assoc) { foreach ($subClass->associationMappings as $assoc) {
if ($assoc->isOwningSide && $assoc->isOneToOne() && ! isset($subClass->inheritedAssociationFields[$assoc->sourceFieldName])) { if ($assoc->isOwningSide && $assoc->isOneToOne() && ! isset($subClass->inheritedAssociationFields[$assoc->sourceFieldName])) {
foreach ($assoc->targetToSourceKeyColumns as $srcColumn) { foreach ($assoc->targetToSourceKeyColumns as $srcColumn) {
$columnList .= ', ' /*. $tableAlias . '.'*/ . $assoc->getQuotedJoinColumnName($srcColumn, $this->_platform); $columnAlias = $srcColumn . $this->_sqlAliasCounter++;
if ($setResultColumnNames) { $columnList .= ', ' . $tableAlias . ".$srcColumn AS $columnAlias";
$resultColumnName = $this->_platform->getSqlResultCasing($srcColumn); $resultColumnName = $this->_platform->getSQLResultCasing($columnAlias);
if ( ! isset($this->_resultColumnNames[$resultColumnName])) {
$this->_resultColumnNames[$resultColumnName] = $srcColumn; $this->_resultColumnNames[$resultColumnName] = $srcColumn;
} }
} }
...@@ -96,14 +91,26 @@ class SingleTablePersister extends StandardEntityPersister ...@@ -96,14 +91,26 @@ class SingleTablePersister extends StandardEntityPersister
{ {
$columns = parent::_getInsertColumnList(); $columns = parent::_getInsertColumnList();
// Add discriminator column to the INSERT SQL // Add discriminator column to the INSERT SQL
$columns[] = $this->_class->getQuotedDiscriminatorColumnName($this->_platform); $columns[] = $this->_class->discriminatorColumn['name'];
return $columns; return $columns;
} }
/** @override */ /** @override */
protected function _processSqlResult(array $sqlResult) protected function _processSQLResult(array $sqlResult)
{ {
return $this->_processSqlResultInheritanceAware($sqlResult); return $this->_processSQLResultInheritanceAware($sqlResult);
}
/** @override */
protected function _getSQLTableAlias(ClassMetadata $class)
{
if (isset($this->_sqlTableAliases[$class->rootEntityName])) {
return $this->_sqlTableAliases[$class->rootEntityName];
}
$tableAlias = $this->_em->getClassMetadata($class->rootEntityName)->primaryTable['name'][0] . $this->_sqlAliasCounter++;
$this->_sqlTableAliases[$class->rootEntityName] = $tableAlias;
return $tableAlias;
} }
} }
\ No newline at end of file
...@@ -23,8 +23,7 @@ namespace Doctrine\ORM\Proxy; ...@@ -23,8 +23,7 @@ namespace Doctrine\ORM\Proxy;
use Doctrine\ORM\EntityManager, use Doctrine\ORM\EntityManager,
Doctrine\ORM\Mapping\ClassMetadata, Doctrine\ORM\Mapping\ClassMetadata,
Doctrine\ORM\Mapping\AssociationMapping, Doctrine\ORM\Mapping\AssociationMapping;
Doctrine\Common\DoctrineException;
/** /**
* This factory is used to create proxy objects for entities at runtime. * This factory is used to create proxy objects for entities at runtime.
...@@ -56,10 +55,10 @@ class ProxyFactory ...@@ -56,10 +55,10 @@ class ProxyFactory
public function __construct(EntityManager $em, $proxyDir, $proxyNs, $autoGenerate = false) public function __construct(EntityManager $em, $proxyDir, $proxyNs, $autoGenerate = false)
{ {
if ( ! $proxyDir) { if ( ! $proxyDir) {
throw DoctrineException::proxyDirectoryRequired(); throw ProxyException::proxyDirectoryRequired();
} }
if ( ! $proxyNs) { if ( ! $proxyNs) {
throw DoctrineException::proxyNamespaceRequired(); throw ProxyException::proxyNamespaceRequired();
} }
$this->_em = $em; $this->_em = $em;
$this->_proxyDir = $proxyDir; $this->_proxyDir = $proxyDir;
......
...@@ -41,7 +41,7 @@ class CurrentDateFunction extends FunctionNode ...@@ -41,7 +41,7 @@ class CurrentDateFunction extends FunctionNode
*/ */
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{ {
return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentDateSql(); return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentDateSQL();
} }
/** /**
......
...@@ -41,7 +41,7 @@ class CurrentTimeFunction extends FunctionNode ...@@ -41,7 +41,7 @@ class CurrentTimeFunction extends FunctionNode
*/ */
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{ {
return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentTimeSql(); return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentTimeSQL();
} }
/** /**
......
...@@ -20,7 +20,7 @@ class CurrentTimestampFunction extends FunctionNode ...@@ -20,7 +20,7 @@ class CurrentTimestampFunction extends FunctionNode
*/ */
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{ {
return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentTimestampSql(); return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentTimestampSQL();
} }
/** /**
......
...@@ -95,8 +95,8 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor ...@@ -95,8 +95,8 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
'type' => \Doctrine\DBAL\Types\Type::getType($rootClass->getTypeOfColumn($idColumnName)) 'type' => \Doctrine\DBAL\Types\Type::getType($rootClass->getTypeOfColumn($idColumnName))
); );
} }
$this->_createTempTableSql = $platform->getCreateTemporaryTableSnippetSql() . ' ' . $tempTable . ' (' $this->_createTempTableSql = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' ('
. $conn->getDatabasePlatform()->getColumnDeclarationListSql($columnDefinitions) . $conn->getDatabasePlatform()->getColumnDeclarationListSQL($columnDefinitions)
. ', PRIMARY KEY(' . $idColumnList . '))'; . ', PRIMARY KEY(' . $idColumnList . '))';
$this->_dropTempTableSql = 'DROP TABLE ' . $tempTable; $this->_dropTempTableSql = 'DROP TABLE ' . $tempTable;
} }
......
...@@ -127,8 +127,8 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor ...@@ -127,8 +127,8 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
'type' => \Doctrine\DBAL\Types\Type::getType($rootClass->getTypeOfColumn($idColumnName)) 'type' => \Doctrine\DBAL\Types\Type::getType($rootClass->getTypeOfColumn($idColumnName))
); );
} }
$this->_createTempTableSql = $platform->getCreateTemporaryTableSnippetSql() . ' ' . $tempTable . ' (' $this->_createTempTableSql = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' ('
. $platform->getColumnDeclarationListSql($columnDefinitions) . $platform->getColumnDeclarationListSQL($columnDefinitions)
. ', PRIMARY KEY(' . $idColumnList . '))'; . ', PRIMARY KEY(' . $idColumnList . '))';
$this->_dropTempTableSql = 'DROP TABLE ' . $tempTable; $this->_dropTempTableSql = 'DROP TABLE ' . $tempTable;
} }
......
...@@ -21,8 +21,7 @@ ...@@ -21,8 +21,7 @@
namespace Doctrine\ORM\Query; namespace Doctrine\ORM\Query;
use Doctrine\Common\DoctrineException, //TODO: Remove use Doctrine\ORM\Query;
Doctrine\ORM\Query;
/** /**
* An LL(*) recursive-descent parser for the context-free grammar of the Doctrine Query Language. * An LL(*) recursive-descent parser for the context-free grammar of the Doctrine Query Language.
......
...@@ -35,7 +35,7 @@ use Doctrine\ORM\Query\AST\PathExpression; ...@@ -35,7 +35,7 @@ use Doctrine\ORM\Query\AST\PathExpression;
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de> * @author Benjamin Eberlei <kontakt@beberlei.de>
*/ */
class QueryException extends \Doctrine\Common\DoctrineException class QueryException extends \Doctrine\ORM\ORMException
{ {
public static function syntaxError($message) public static function syntaxError($message)
{ {
...@@ -75,6 +75,10 @@ class QueryException extends \Doctrine\Common\DoctrineException ...@@ -75,6 +75,10 @@ class QueryException extends \Doctrine\Common\DoctrineException
); );
} }
public static function invalidLiteral($literal) {
return new self("Invalid literal '$literal'");
}
/** /**
* @param Doctrine\ORM\Mapping\AssociationMapping $assoc * @param Doctrine\ORM\Mapping\AssociationMapping $assoc
*/ */
...@@ -112,6 +116,11 @@ class QueryException extends \Doctrine\Common\DoctrineException ...@@ -112,6 +116,11 @@ class QueryException extends \Doctrine\Common\DoctrineException
); );
} }
// TODO: Add the $assoc to the error message
public static function iterateWithFetchJoinNotAllowed($assoc) {
return new self("Iterate with fetch join not allowed");
}
public static function associationPathCompositeKeyNotSupported() public static function associationPathCompositeKeyNotSupported()
{ {
return new self( return new self(
......
...@@ -161,6 +161,7 @@ class ResultSetMapping ...@@ -161,6 +161,7 @@ class ResultSetMapping
* *
* @param string $alias * @param string $alias
* @return boolean * @return boolean
* @todo Rename: isIndexed($alias)
*/ */
public function hasIndexBy($alias) public function hasIndexBy($alias)
{ {
...@@ -380,11 +381,11 @@ class ResultSetMapping ...@@ -380,11 +381,11 @@ class ResultSetMapping
} }
/** /**
* Adds a meta column (foreign key or discriminator column) to the result set.
* *
* @param $alias * @param $alias
* @param $columnName * @param $columnName
* @param $fieldName * @param $fieldName
* @return unknown_type
*/ */
public function addMetaResult($alias, $columnName, $fieldName) public function addMetaResult($alias, $columnName, $fieldName)
{ {
......
This diff is collapsed.
...@@ -21,8 +21,7 @@ ...@@ -21,8 +21,7 @@
namespace Doctrine\ORM\Tools; namespace Doctrine\ORM\Tools;
use Doctrine\Common\DoctrineException, use Doctrine\ORM\Mapping\ClassMetadataInfo,
Doctrine\ORM\Mapping\ClassMetadataInfo,
Doctrine\ORM\Tools\Export\Driver\AbstractExporter, Doctrine\ORM\Tools\Export\Driver\AbstractExporter,
Doctrine\Common\Util\Inflector; Doctrine\Common\Util\Inflector;
...@@ -169,7 +168,7 @@ class ConvertDoctrine1Schema ...@@ -169,7 +168,7 @@ class ConvertDoctrine1Schema
$column['type'] = $this->_legacyTypeMap[$column['type']]; $column['type'] = $this->_legacyTypeMap[$column['type']];
} }
if ( ! \Doctrine\DBAL\Types\Type::hasType($column['type'])) { if ( ! \Doctrine\DBAL\Types\Type::hasType($column['type'])) {
throw DoctrineException::couldNotMapDoctrine1Type($column['type']); throw ToolsException::couldNotMapDoctrine1Type($column['type']);
} }
$fieldMapping = array(); $fieldMapping = array();
......
...@@ -25,7 +25,7 @@ namespace Doctrine\ORM\Tools\Export; ...@@ -25,7 +25,7 @@ namespace Doctrine\ORM\Tools\Export;
use Doctrine\ORM\EntityManager, use Doctrine\ORM\EntityManager,
Doctrine\ORM\Mapping\ClassMetadataInfo, Doctrine\ORM\Mapping\ClassMetadataInfo,
Doctrine\ORM\Mapping\ClassMetadata, Doctrine\ORM\Mapping\ClassMetadata,
Doctrine\Common\DoctrineException; Doctrine\ORM\Mapping\MappingException;
/** /**
* Class used for converting your mapping information between the * Class used for converting your mapping information between the
...@@ -89,7 +89,7 @@ class ClassMetadataExporter ...@@ -89,7 +89,7 @@ class ClassMetadataExporter
public function addMappingSource($source, $type) public function addMappingSource($source, $type)
{ {
if ( ! isset($this->_mappingDrivers[$type])) { if ( ! isset($this->_mappingDrivers[$type])) {
throw DoctrineException::invalidMappingDriverType($type); throw ExportException::invalidMappingDriverType($type);
} }
$driver = $this->getMappingDriver($type, $source); $driver = $this->getMappingDriver($type, $source);
...@@ -117,7 +117,7 @@ class ClassMetadataExporter ...@@ -117,7 +117,7 @@ class ClassMetadataExporter
if (is_subclass_of($class, 'Doctrine\ORM\Mapping\Driver\AbstractFileDriver')) { if (is_subclass_of($class, 'Doctrine\ORM\Mapping\Driver\AbstractFileDriver')) {
if (is_null($source)) { if (is_null($source)) {
throw DoctrineException::fileMappingDriversRequireDirectoryPath(); throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath();
} }
$driver = new $class($source); $driver = new $class($source);
...@@ -187,7 +187,7 @@ class ClassMetadataExporter ...@@ -187,7 +187,7 @@ class ClassMetadataExporter
public function getExporter($type, $source = null) public function getExporter($type, $source = null)
{ {
if ( ! isset($this->_exporterDrivers[$type])) { if ( ! isset($this->_exporterDrivers[$type])) {
throw DoctrineException::invalidExporterDriverType($type); throw ExportException::invalidExporterDriverType($type);
} }
$class = $this->_exporterDrivers[$type]; $class = $this->_exporterDrivers[$type];
......
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
namespace Doctrine\ORM\Tools; namespace Doctrine\ORM\Tools;
use Doctrine\DBAL\Types\Type, use Doctrine\ORM\ORMException,
Doctrine\DBAL\Types\Type,
Doctrine\ORM\EntityManager, Doctrine\ORM\EntityManager,
Doctrine\ORM\Internal\CommitOrderCalculator; Doctrine\ORM\Internal\CommitOrderCalculator;
...@@ -191,7 +192,7 @@ class SchemaTool ...@@ -191,7 +192,7 @@ class SchemaTool
$table->setPrimaryKey($pkColumns); $table->setPrimaryKey($pkColumns);
} else if ($class->isInheritanceTypeTablePerClass()) { } else if ($class->isInheritanceTypeTablePerClass()) {
throw DoctrineException::notSupported(); throw ORMException::notSupported();
} else { } else {
$this->_gatherColumns($class, $table); $this->_gatherColumns($class, $table);
$this->_gatherRelationsSql($class, $table, $schema); $this->_gatherRelationsSql($class, $table, $schema);
...@@ -245,7 +246,7 @@ class SchemaTool ...@@ -245,7 +246,7 @@ class SchemaTool
} }
$table->addColumn( $table->addColumn(
$class->getQuotedDiscriminatorColumnName($this->_platform), $discrColumn['name'],
$discrColumn['type'], $discrColumn['type'],
array('length' => $discrColumn['length'], 'notnull' => true) array('length' => $discrColumn['length'], 'notnull' => true)
); );
...@@ -357,7 +358,7 @@ class SchemaTool ...@@ -357,7 +358,7 @@ class SchemaTool
$this->_gatherRelationJoinColumns($mapping->getJoinColumns(), $table, $foreignClass, $mapping, $primaryKeyColumns, $uniqueConstraints); $this->_gatherRelationJoinColumns($mapping->getJoinColumns(), $table, $foreignClass, $mapping, $primaryKeyColumns, $uniqueConstraints);
} else if ($mapping->isOneToMany() && $mapping->isOwningSide) { } else if ($mapping->isOneToMany() && $mapping->isOwningSide) {
//... create join table, one-many through join table supported later //... create join table, one-many through join table supported later
throw DoctrineException::notSupported(); throw ORMException::notSupported();
} else if ($mapping->isManyToMany() && $mapping->isOwningSide) { } else if ($mapping->isManyToMany() && $mapping->isOwningSide) {
// create join table // create join table
$joinTable = $mapping->getJoinTable(); $joinTable = $mapping->getJoinTable();
...@@ -400,12 +401,11 @@ class SchemaTool ...@@ -400,12 +401,11 @@ class SchemaTool
$fkOptions = array(); $fkOptions = array();
foreach ($joinColumns as $joinColumn) { foreach ($joinColumns as $joinColumn) {
// Note that this thing might be quoted, i.e. `foo`, [foo], ... $columnName = $joinColumn['name'];
$columnName = $mapping->getQuotedJoinColumnName($joinColumn['name'], $this->_platform);
$referencedFieldName = $class->getFieldName($joinColumn['referencedColumnName']); $referencedFieldName = $class->getFieldName($joinColumn['referencedColumnName']);
if (!$class->hasField($referencedFieldName)) { if ( ! $class->hasField($referencedFieldName)) {
throw new \Doctrine\Common\DoctrineException( throw new \Doctrine\ORM\ORMException(
"Column name `".$joinColumn['referencedColumnName']."` referenced for relation from ". "Column name `".$joinColumn['referencedColumnName']."` referenced for relation from ".
"$mapping->sourceEntityName towards $mapping->targetEntityName does not exist." "$mapping->sourceEntityName towards $mapping->targetEntityName does not exist."
); );
......
...@@ -375,7 +375,7 @@ class UnitOfWork implements PropertyChangedListener ...@@ -375,7 +375,7 @@ class UnitOfWork implements PropertyChangedListener
* *
* @Internal * @Internal
* *
* @Todo inline _computeChangeSet to here? * @Todo inline _computeEntityChanges to here?
* *
* @param ClassMetadata $class * @param ClassMetadata $class
* @param object $entity * @param object $entity
......
...@@ -23,7 +23,6 @@ class AllTests ...@@ -23,7 +23,6 @@ class AllTests
{ {
$suite = new \Doctrine\Tests\DoctrineTestSuite('Doctrine Common Tests'); $suite = new \Doctrine\Tests\DoctrineTestSuite('Doctrine Common Tests');
$suite->addTestSuite('Doctrine\Tests\Common\DoctrineExceptionTest');
$suite->addTestSuite('Doctrine\Tests\Common\ClassLoaderTest'); $suite->addTestSuite('Doctrine\Tests\Common\ClassLoaderTest');
$suite->addTestSuite('Doctrine\Tests\Common\EventManagerTest'); $suite->addTestSuite('Doctrine\Tests\Common\EventManagerTest');
......
...@@ -11,7 +11,7 @@ class ClassLoaderTest extends \Doctrine\Tests\DoctrineTestCase ...@@ -11,7 +11,7 @@ class ClassLoaderTest extends \Doctrine\Tests\DoctrineTestCase
{ {
public function testGlobalClassLoaderThrowsExceptionIfPutInChain() public function testGlobalClassLoaderThrowsExceptionIfPutInChain()
{ {
$this->setExpectedException('Doctrine\Common\DoctrineException'); $this->setExpectedException('Doctrine\Common\CommonException');
$classLoader1 = new IsolatedClassLoader('Foo'); $classLoader1 = new IsolatedClassLoader('Foo');
$classLoader1->register(); $classLoader1->register();
......
<?php
namespace Doctrine\Tests\Common;
require_once __DIR__ . '/../TestInit.php';
class DoctrineExceptionTest extends \Doctrine\Tests\DoctrineTestCase
{
/*public function testStaticCall()
{
$e = \Doctrine\Common\DoctrineException::testingStaticCallBuildsErrorMessageWithParams('param1', 'param2');
$this->assertEquals($e->getMessage(), "Testing static call builds error message with params ('param1', 'param2')");
}*/
public function testInnerException()
{
$e1 = \Doctrine\Common\DoctrineException::testException();
$e2 = \Doctrine\Common\DoctrineException::testException2('param1', $e1);
$this->assertEquals($e1, $e2->getPrevious());
}
public function testNotImplemented()
{
$e = \Doctrine\Common\DoctrineException::notImplemented('testMethod', 'SomeClass');
$this->assertEquals("The method 'testMethod' is not implemented in class 'SomeClass'.", $e->getMessage());
}
public function testGetExceptionMessage()
{
$this->assertEquals('The query contains more than one result.', \Doctrine\Common\DoctrineException::getExceptionMessage('QueryException#nonUniqueResult'));
}
public function testUseGetExceptionMessage()
{
$q = \Doctrine\ORM\Query\QueryException::nonUniqueResult();
$this->assertEquals('The query contains more than one result.', $q->getMessage());
}
}
\ No newline at end of file
...@@ -6,19 +6,19 @@ use Doctrine\DBAL\Platforms; ...@@ -6,19 +6,19 @@ use Doctrine\DBAL\Platforms;
class MockPlatform extends \Doctrine\DBAL\Platforms\AbstractPlatform class MockPlatform extends \Doctrine\DBAL\Platforms\AbstractPlatform
{ {
public function getBooleanTypeDeclarationSql(array $columnDef) {} public function getBooleanTypeDeclarationSQL(array $columnDef) {}
public function getIntegerTypeDeclarationSql(array $columnDef) {} public function getIntegerTypeDeclarationSQL(array $columnDef) {}
public function getBigIntTypeDeclarationSql(array $columnDef) {} public function getBigIntTypeDeclarationSQL(array $columnDef) {}
public function getSmallIntTypeDeclarationSql(array $columnDef) {} public function getSmallIntTypeDeclarationSQL(array $columnDef) {}
public function _getCommonIntegerTypeDeclarationSql(array $columnDef) {} public function _getCommonIntegerTypeDeclarationSQL(array $columnDef) {}
public function getVarcharTypeDeclarationSql(array $field) public function getVarcharTypeDeclarationSQL(array $field)
{ {
return "DUMMYVARCHAR()"; return "DUMMYVARCHAR()";
} }
/** @override */ /** @override */
public function getClobTypeDeclarationSql(array $field) public function getClobTypeDeclarationSQL(array $field)
{ {
return 'DUMMYCLOB'; return 'DUMMYCLOB';
} }
......
...@@ -21,7 +21,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase ...@@ -21,7 +21,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$table = new \Doctrine\DBAL\Schema\Table('test'); $table = new \Doctrine\DBAL\Schema\Table('test');
$this->setExpectedException('Doctrine\DBAL\DBALException'); $this->setExpectedException('Doctrine\DBAL\DBALException');
$sql = $this->_platform->getCreateTableSql($table); $sql = $this->_platform->getCreateTableSQL($table);
} }
public function testGeneratesTableCreationSql() public function testGeneratesTableCreationSql()
...@@ -32,7 +32,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase ...@@ -32,7 +32,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$table->setPrimaryKey(array('id')); $table->setPrimaryKey(array('id'));
$table->setIdGeneratorType(\Doctrine\DBAL\Schema\Table::ID_IDENTITY); $table->setIdGeneratorType(\Doctrine\DBAL\Schema\Table::ID_IDENTITY);
$sql = $this->_platform->getCreateTableSql($table); $sql = $this->_platform->getCreateTableSQL($table);
$this->assertEquals($this->getGenerateTableSql(), $sql[0]); $this->assertEquals($this->getGenerateTableSql(), $sql[0]);
} }
...@@ -45,7 +45,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase ...@@ -45,7 +45,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$table->addColumn('bar', 'string', array('notnull' => false, 'length' => 255)); $table->addColumn('bar', 'string', array('notnull' => false, 'length' => 255));
$table->addUniqueIndex(array("foo", "bar")); $table->addUniqueIndex(array("foo", "bar"));
$sql = $this->_platform->getCreateTableSql($table); $sql = $this->_platform->getCreateTableSQL($table);
$this->assertEquals($this->getGenerateTableWithMultiColumnUniqueIndexSql(), $sql); $this->assertEquals($this->getGenerateTableWithMultiColumnUniqueIndexSql(), $sql);
} }
...@@ -57,7 +57,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase ...@@ -57,7 +57,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this->assertEquals( $this->assertEquals(
$this->getGenerateIndexSql(), $this->getGenerateIndexSql(),
$this->_platform->getCreateIndexSql($indexDef, 'mytable') $this->_platform->getCreateIndexSQL($indexDef, 'mytable')
); );
} }
...@@ -67,7 +67,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase ...@@ -67,7 +67,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
{ {
$indexDef = new \Doctrine\DBAL\Schema\Index('index_name', array('test', 'test2'), true); $indexDef = new \Doctrine\DBAL\Schema\Index('index_name', array('test', 'test2'), true);
$sql = $this->_platform->getCreateIndexSql($indexDef, 'test'); $sql = $this->_platform->getCreateIndexSQL($indexDef, 'test');
$this->assertEquals($this->getGenerateUniqueIndexSql(), $sql); $this->assertEquals($this->getGenerateUniqueIndexSql(), $sql);
} }
...@@ -77,7 +77,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase ...@@ -77,7 +77,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
{ {
$fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name_id'), 'other_table', array('id'), ''); $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name_id'), 'other_table', array('id'), '');
$sql = $this->_platform->getCreateForeignKeySql($fk, 'test'); $sql = $this->_platform->getCreateForeignKeySQL($fk, 'test');
$this->assertEquals($sql, $this->getGenerateForeignKeySql()); $this->assertEquals($sql, $this->getGenerateForeignKeySql());
} }
...@@ -86,15 +86,15 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase ...@@ -86,15 +86,15 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
public function testGeneratesConstraintCreationSql() public function testGeneratesConstraintCreationSql()
{ {
$idx = new \Doctrine\DBAL\Schema\Index('constraint_name', array('test'), true, false); $idx = new \Doctrine\DBAL\Schema\Index('constraint_name', array('test'), true, false);
$sql = $this->_platform->getCreateConstraintSql($idx, 'test'); $sql = $this->_platform->getCreateConstraintSQL($idx, 'test');
$this->assertEquals($this->getGenerateConstraintUniqueIndexSql(), $sql); $this->assertEquals($this->getGenerateConstraintUniqueIndexSql(), $sql);
$pk = new \Doctrine\DBAL\Schema\Index('constraint_name', array('test'), true, true); $pk = new \Doctrine\DBAL\Schema\Index('constraint_name', array('test'), true, true);
$sql = $this->_platform->getCreateConstraintSql($pk, 'test'); $sql = $this->_platform->getCreateConstraintSQL($pk, 'test');
$this->assertEquals($this->getGenerateConstraintPrimaryIndexSql(), $sql); $this->assertEquals($this->getGenerateConstraintPrimaryIndexSql(), $sql);
$fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name'), 'foreign', array('id'), 'constraint_fk'); $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name'), 'foreign', array('id'), 'constraint_fk');
$sql = $this->_platform->getCreateConstraintSql($fk, 'test'); $sql = $this->_platform->getCreateConstraintSQL($fk, 'test');
$this->assertEquals($this->getGenerateConstraintForeignKeySql(), $sql); $this->assertEquals($this->getGenerateConstraintForeignKeySql(), $sql);
} }
...@@ -132,7 +132,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase ...@@ -132,7 +132,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$tableDiff->removedColumns['foo'] = new \Doctrine\DBAL\Schema\Column('foo', \Doctrine\DBAL\Types\Type::getType('integer')); $tableDiff->removedColumns['foo'] = new \Doctrine\DBAL\Schema\Column('foo', \Doctrine\DBAL\Types\Type::getType('integer'));
$tableDiff->changedColumns['bar'] = $columnDiff; $tableDiff->changedColumns['bar'] = $columnDiff;
$sql = $this->_platform->getAlterTableSql($tableDiff); $sql = $this->_platform->getAlterTableSQL($tableDiff);
$this->assertEquals($expectedSql, $sql); $this->assertEquals($expectedSql, $sql);
} }
...@@ -140,6 +140,6 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase ...@@ -140,6 +140,6 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
public function testGetCustomColumnDeclarationSql() public function testGetCustomColumnDeclarationSql()
{ {
$field = array('columnDefinition' => 'MEDIUMINT(6) UNSIGNED'); $field = array('columnDefinition' => 'MEDIUMINT(6) UNSIGNED');
$this->assertEquals('foo MEDIUMINT(6) UNSIGNED', $this->_platform->getColumnDeclarationSql('foo', $field)); $this->assertEquals('foo MEDIUMINT(6) UNSIGNED', $this->_platform->getColumnDeclarationSQL('foo', $field));
} }
} }
...@@ -44,43 +44,43 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase ...@@ -44,43 +44,43 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase
{ {
$this->assertEquals( $this->assertEquals(
'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED',
$this->_platform->getSetTransactionIsolationSql(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED) $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED)
); );
$this->assertEquals( $this->assertEquals(
'SET TRANSACTION ISOLATION LEVEL READ COMMITTED', 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED',
$this->_platform->getSetTransactionIsolationSql(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED) $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED)
); );
$this->assertEquals( $this->assertEquals(
'SET TRANSACTION ISOLATION LEVEL REPEATABLE READ', 'SET TRANSACTION ISOLATION LEVEL REPEATABLE READ',
$this->_platform->getSetTransactionIsolationSql(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ) $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ)
); );
$this->assertEquals( $this->assertEquals(
'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE', 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE',
$this->_platform->getSetTransactionIsolationSql(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE) $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE)
); );
} }
public function testGeneratesDDLSnippets() public function testGeneratesDDLSnippets()
{ {
$this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSql()); $this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSQL());
$this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSql('foobar')); $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar'));
$this->assertEquals('DROP DATABASE foobar', $this->_platform->getDropDatabaseSql('foobar')); $this->assertEquals('DROP DATABASE foobar', $this->_platform->getDropDatabaseSQL('foobar'));
$this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSql('foobar')); $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar'));
} }
public function testGeneratesTypeDeclarationForIntegers() public function testGeneratesTypeDeclarationForIntegers()
{ {
$this->assertEquals( $this->assertEquals(
'INT', 'INT',
$this->_platform->getIntegerTypeDeclarationSql(array()) $this->_platform->getIntegerTypeDeclarationSQL(array())
); );
$this->assertEquals( $this->assertEquals(
'INT AUTO_INCREMENT', 'INT AUTO_INCREMENT',
$this->_platform->getIntegerTypeDeclarationSql(array('autoincrement' => true) $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true)
)); ));
$this->assertEquals( $this->assertEquals(
'INT AUTO_INCREMENT', 'INT AUTO_INCREMENT',
$this->_platform->getIntegerTypeDeclarationSql( $this->_platform->getIntegerTypeDeclarationSQL(
array('autoincrement' => true, 'primary' => true) array('autoincrement' => true, 'primary' => true)
)); ));
} }
...@@ -89,17 +89,17 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase ...@@ -89,17 +89,17 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase
{ {
$this->assertEquals( $this->assertEquals(
'CHAR(10)', 'CHAR(10)',
$this->_platform->getVarcharTypeDeclarationSql( $this->_platform->getVarcharTypeDeclarationSQL(
array('length' => 10, 'fixed' => true) array('length' => 10, 'fixed' => true)
)); ));
$this->assertEquals( $this->assertEquals(
'VARCHAR(50)', 'VARCHAR(50)',
$this->_platform->getVarcharTypeDeclarationSql(array('length' => 50)), $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)),
'Variable string declaration is not correct' 'Variable string declaration is not correct'
); );
$this->assertEquals( $this->assertEquals(
'TEXT', 'TEXT',
$this->_platform->getVarcharTypeDeclarationSql(array()), $this->_platform->getVarcharTypeDeclarationSQL(array()),
'Long string declaration is not correct' 'Long string declaration is not correct'
); );
} }
......
...@@ -19,7 +19,7 @@ class MySqlPlatformTest extends AbstractPlatformTestCase ...@@ -19,7 +19,7 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
$table = new \Doctrine\DBAL\Schema\Table("Foo"); $table = new \Doctrine\DBAL\Schema\Table("Foo");
$table->addColumn("Bar", "integer"); $table->addColumn("Bar", "integer");
$sql = $this->_platform->getCreateTableSql($table); $sql = $this->_platform->getCreateTableSQL($table);
$this->assertEquals('CREATE TABLE Foo (Bar INT NOT NULL) ENGINE = InnoDB', array_shift($sql)); $this->assertEquals('CREATE TABLE Foo (Bar INT NOT NULL) ENGINE = InnoDB', array_shift($sql));
} }
...@@ -53,45 +53,45 @@ class MySqlPlatformTest extends AbstractPlatformTestCase ...@@ -53,45 +53,45 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
{ {
$this->assertEquals( $this->assertEquals(
'SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', 'SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED',
$this->_platform->getSetTransactionIsolationSql(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED), $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED),
'' ''
); );
$this->assertEquals( $this->assertEquals(
'SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED', 'SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED',
$this->_platform->getSetTransactionIsolationSql(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED) $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED)
); );
$this->assertEquals( $this->assertEquals(
'SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ', 'SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ',
$this->_platform->getSetTransactionIsolationSql(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ) $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ)
); );
$this->assertEquals( $this->assertEquals(
'SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE', 'SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE',
$this->_platform->getSetTransactionIsolationSql(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE) $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE)
); );
} }
public function testGeneratesDDLSnippets() public function testGeneratesDDLSnippets()
{ {
$this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSql()); $this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSQL());
$this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSql('foobar')); $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar'));
$this->assertEquals('DROP DATABASE foobar', $this->_platform->getDropDatabaseSql('foobar')); $this->assertEquals('DROP DATABASE foobar', $this->_platform->getDropDatabaseSQL('foobar'));
$this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSql('foobar')); $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar'));
} }
public function testGeneratesTypeDeclarationForIntegers() public function testGeneratesTypeDeclarationForIntegers()
{ {
$this->assertEquals( $this->assertEquals(
'INT', 'INT',
$this->_platform->getIntegerTypeDeclarationSql(array()) $this->_platform->getIntegerTypeDeclarationSQL(array())
); );
$this->assertEquals( $this->assertEquals(
'INT AUTO_INCREMENT', 'INT AUTO_INCREMENT',
$this->_platform->getIntegerTypeDeclarationSql(array('autoincrement' => true) $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true)
)); ));
$this->assertEquals( $this->assertEquals(
'INT AUTO_INCREMENT', 'INT AUTO_INCREMENT',
$this->_platform->getIntegerTypeDeclarationSql( $this->_platform->getIntegerTypeDeclarationSQL(
array('autoincrement' => true, 'primary' => true) array('autoincrement' => true, 'primary' => true)
)); ));
} }
...@@ -100,17 +100,17 @@ class MySqlPlatformTest extends AbstractPlatformTestCase ...@@ -100,17 +100,17 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
{ {
$this->assertEquals( $this->assertEquals(
'CHAR(10)', 'CHAR(10)',
$this->_platform->getVarcharTypeDeclarationSql( $this->_platform->getVarcharTypeDeclarationSQL(
array('length' => 10, 'fixed' => true) array('length' => 10, 'fixed' => true)
)); ));
$this->assertEquals( $this->assertEquals(
'VARCHAR(50)', 'VARCHAR(50)',
$this->_platform->getVarcharTypeDeclarationSql(array('length' => 50)), $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)),
'Variable string declaration is not correct' 'Variable string declaration is not correct'
); );
$this->assertEquals( $this->assertEquals(
'VARCHAR(255)', 'VARCHAR(255)',
$this->_platform->getVarcharTypeDeclarationSql(array()), $this->_platform->getVarcharTypeDeclarationSQL(array()),
'Long string declaration is not correct' 'Long string declaration is not correct'
); );
} }
...@@ -162,8 +162,8 @@ class MySqlPlatformTest extends AbstractPlatformTestCase ...@@ -162,8 +162,8 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
*/ */
public function testGetDateTimeTypeDeclarationSql() public function testGetDateTimeTypeDeclarationSql()
{ {
$this->assertEquals("DATETIME", $this->_platform->getDateTimeTypeDeclarationSql(array('version' => false))); $this->assertEquals("DATETIME", $this->_platform->getDateTimeTypeDeclarationSQL(array('version' => false)));
$this->assertEquals("TIMESTAMP", $this->_platform->getDateTimeTypeDeclarationSql(array('version' => true))); $this->assertEquals("TIMESTAMP", $this->_platform->getDateTimeTypeDeclarationSQL(array('version' => true)));
$this->assertEquals("DATETIME", $this->_platform->getDateTimeTypeDeclarationSql(array())); $this->assertEquals("DATETIME", $this->_platform->getDateTimeTypeDeclarationSQL(array()));
} }
} }
\ No newline at end of file
...@@ -55,19 +55,19 @@ class OraclePlatformTest extends AbstractPlatformTestCase ...@@ -55,19 +55,19 @@ class OraclePlatformTest extends AbstractPlatformTestCase
{ {
$this->assertEquals( $this->assertEquals(
'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED',
$this->_platform->getSetTransactionIsolationSql(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED) $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED)
); );
$this->assertEquals( $this->assertEquals(
'SET TRANSACTION ISOLATION LEVEL READ COMMITTED', 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED',
$this->_platform->getSetTransactionIsolationSql(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED) $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED)
); );
$this->assertEquals( $this->assertEquals(
'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE', 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE',
$this->_platform->getSetTransactionIsolationSql(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ) $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ)
); );
$this->assertEquals( $this->assertEquals(
'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE', 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE',
$this->_platform->getSetTransactionIsolationSql(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE) $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE)
); );
} }
...@@ -76,7 +76,7 @@ class OraclePlatformTest extends AbstractPlatformTestCase ...@@ -76,7 +76,7 @@ class OraclePlatformTest extends AbstractPlatformTestCase
*/ */
public function testShowDatabasesThrowsException() public function testShowDatabasesThrowsException()
{ {
$this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSql()); $this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSQL());
} }
/** /**
...@@ -84,32 +84,32 @@ class OraclePlatformTest extends AbstractPlatformTestCase ...@@ -84,32 +84,32 @@ class OraclePlatformTest extends AbstractPlatformTestCase
*/ */
public function testCreateDatabaseThrowsException() public function testCreateDatabaseThrowsException()
{ {
$this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSql('foobar')); $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar'));
} }
public function testDropDatabaseThrowsException() public function testDropDatabaseThrowsException()
{ {
$this->assertEquals('DROP USER foobar CASCADE', $this->_platform->getDropDatabaseSql('foobar')); $this->assertEquals('DROP USER foobar CASCADE', $this->_platform->getDropDatabaseSQL('foobar'));
} }
public function testDropTable() public function testDropTable()
{ {
$this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSql('foobar')); $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar'));
} }
public function testGeneratesTypeDeclarationForIntegers() public function testGeneratesTypeDeclarationForIntegers()
{ {
$this->assertEquals( $this->assertEquals(
'NUMBER(10)', 'NUMBER(10)',
$this->_platform->getIntegerTypeDeclarationSql(array()) $this->_platform->getIntegerTypeDeclarationSQL(array())
); );
$this->assertEquals( $this->assertEquals(
'NUMBER(10)', 'NUMBER(10)',
$this->_platform->getIntegerTypeDeclarationSql(array('autoincrement' => true) $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true)
)); ));
$this->assertEquals( $this->assertEquals(
'NUMBER(10)', 'NUMBER(10)',
$this->_platform->getIntegerTypeDeclarationSql( $this->_platform->getIntegerTypeDeclarationSQL(
array('autoincrement' => true, 'primary' => true) array('autoincrement' => true, 'primary' => true)
)); ));
} }
...@@ -118,17 +118,17 @@ class OraclePlatformTest extends AbstractPlatformTestCase ...@@ -118,17 +118,17 @@ class OraclePlatformTest extends AbstractPlatformTestCase
{ {
$this->assertEquals( $this->assertEquals(
'CHAR(10)', 'CHAR(10)',
$this->_platform->getVarcharTypeDeclarationSql( $this->_platform->getVarcharTypeDeclarationSQL(
array('length' => 10, 'fixed' => true) array('length' => 10, 'fixed' => true)
)); ));
$this->assertEquals( $this->assertEquals(
'VARCHAR2(50)', 'VARCHAR2(50)',
$this->_platform->getVarcharTypeDeclarationSql(array('length' => 50)), $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)),
'Variable string declaration is not correct' 'Variable string declaration is not correct'
); );
$this->assertEquals( $this->assertEquals(
'VARCHAR2(4000)', 'VARCHAR2(4000)',
$this->_platform->getVarcharTypeDeclarationSql(array()), $this->_platform->getVarcharTypeDeclarationSQL(array()),
'Long string declaration is not correct' 'Long string declaration is not correct'
); );
} }
......
...@@ -57,7 +57,7 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase ...@@ -57,7 +57,7 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
); );
$this->assertEquals( $this->assertEquals(
"CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table(id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE", "CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table(id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE",
$this->_platform->getForeignKeyDeclarationSql($foreignKey) $this->_platform->getForeignKeyDeclarationSQL($foreignKey)
); );
} }
...@@ -74,42 +74,42 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase ...@@ -74,42 +74,42 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
{ {
$this->assertEquals( $this->assertEquals(
'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ UNCOMMITTED',
$this->_platform->getSetTransactionIsolationSql(Connection::TRANSACTION_READ_UNCOMMITTED) $this->_platform->getSetTransactionIsolationSQL(Connection::TRANSACTION_READ_UNCOMMITTED)
); );
$this->assertEquals( $this->assertEquals(
'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ COMMITTED', 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ COMMITTED',
$this->_platform->getSetTransactionIsolationSql(Connection::TRANSACTION_READ_COMMITTED) $this->_platform->getSetTransactionIsolationSQL(Connection::TRANSACTION_READ_COMMITTED)
); );
$this->assertEquals( $this->assertEquals(
'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL REPEATABLE READ', 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL REPEATABLE READ',
$this->_platform->getSetTransactionIsolationSql(Connection::TRANSACTION_REPEATABLE_READ) $this->_platform->getSetTransactionIsolationSQL(Connection::TRANSACTION_REPEATABLE_READ)
); );
$this->assertEquals( $this->assertEquals(
'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE', 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE',
$this->_platform->getSetTransactionIsolationSql(Connection::TRANSACTION_SERIALIZABLE) $this->_platform->getSetTransactionIsolationSQL(Connection::TRANSACTION_SERIALIZABLE)
); );
} }
public function testGeneratesDDLSnippets() public function testGeneratesDDLSnippets()
{ {
$this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSql('foobar')); $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar'));
$this->assertEquals('DROP DATABASE foobar', $this->_platform->getDropDatabaseSql('foobar')); $this->assertEquals('DROP DATABASE foobar', $this->_platform->getDropDatabaseSQL('foobar'));
$this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSql('foobar')); $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar'));
} }
public function testGeneratesTypeDeclarationForIntegers() public function testGeneratesTypeDeclarationForIntegers()
{ {
$this->assertEquals( $this->assertEquals(
'INT', 'INT',
$this->_platform->getIntegerTypeDeclarationSql(array()) $this->_platform->getIntegerTypeDeclarationSQL(array())
); );
$this->assertEquals( $this->assertEquals(
'SERIAL', 'SERIAL',
$this->_platform->getIntegerTypeDeclarationSql(array('autoincrement' => true) $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true)
)); ));
$this->assertEquals( $this->assertEquals(
'SERIAL', 'SERIAL',
$this->_platform->getIntegerTypeDeclarationSql( $this->_platform->getIntegerTypeDeclarationSQL(
array('autoincrement' => true, 'primary' => true) array('autoincrement' => true, 'primary' => true)
)); ));
} }
...@@ -118,17 +118,17 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase ...@@ -118,17 +118,17 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
{ {
$this->assertEquals( $this->assertEquals(
'CHAR(10)', 'CHAR(10)',
$this->_platform->getVarcharTypeDeclarationSql( $this->_platform->getVarcharTypeDeclarationSQL(
array('length' => 10, 'fixed' => true)) array('length' => 10, 'fixed' => true))
); );
$this->assertEquals( $this->assertEquals(
'VARCHAR(50)', 'VARCHAR(50)',
$this->_platform->getVarcharTypeDeclarationSql(array('length' => 50)), $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)),
'Variable string declaration is not correct' 'Variable string declaration is not correct'
); );
$this->assertEquals( $this->assertEquals(
'TEXT', 'TEXT',
$this->_platform->getVarcharTypeDeclarationSql(array()), $this->_platform->getVarcharTypeDeclarationSQL(array()),
'Long string declaration is not correct' 'Long string declaration is not correct'
); );
} }
...@@ -143,15 +143,15 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase ...@@ -143,15 +143,15 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
$sequence = new \Doctrine\DBAL\Schema\Sequence('myseq', 20, 1); $sequence = new \Doctrine\DBAL\Schema\Sequence('myseq', 20, 1);
$this->assertEquals( $this->assertEquals(
'CREATE SEQUENCE myseq INCREMENT BY 20 MINVALUE 1 START 1', 'CREATE SEQUENCE myseq INCREMENT BY 20 MINVALUE 1 START 1',
$this->_platform->getCreateSequenceSql($sequence) $this->_platform->getCreateSequenceSQL($sequence)
); );
$this->assertEquals( $this->assertEquals(
'DROP SEQUENCE myseq', 'DROP SEQUENCE myseq',
$this->_platform->getDropSequenceSql('myseq') $this->_platform->getDropSequenceSQL('myseq')
); );
$this->assertEquals( $this->assertEquals(
"SELECT NEXTVAL('myseq')", "SELECT NEXTVAL('myseq')",
$this->_platform->getSequenceNextValSql('myseq') $this->_platform->getSequenceNextValSQL('myseq')
); );
} }
......
...@@ -36,10 +36,10 @@ class SqlitePlatformTest extends AbstractPlatformTestCase ...@@ -36,10 +36,10 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
public function testGeneratesTransactionCommands() public function testGeneratesTransactionCommands()
{ {
$this->assertEquals('PRAGMA read_uncommitted = 0', $this->_platform->getSetTransactionIsolationSql(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED)); $this->assertEquals('PRAGMA read_uncommitted = 0', $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED));
$this->assertEquals('PRAGMA read_uncommitted = 1', $this->_platform->getSetTransactionIsolationSql(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED)); $this->assertEquals('PRAGMA read_uncommitted = 1', $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED));
$this->assertEquals('PRAGMA read_uncommitted = 1', $this->_platform->getSetTransactionIsolationSql(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ)); $this->assertEquals('PRAGMA read_uncommitted = 1', $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ));
$this->assertEquals('PRAGMA read_uncommitted = 1', $this->_platform->getSetTransactionIsolationSql(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE)); $this->assertEquals('PRAGMA read_uncommitted = 1', $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE));
} }
public function testPrefersIdentityColumns() public function testPrefersIdentityColumns()
...@@ -51,15 +51,15 @@ class SqlitePlatformTest extends AbstractPlatformTestCase ...@@ -51,15 +51,15 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
{ {
$this->assertEquals( $this->assertEquals(
'INTEGER', 'INTEGER',
$this->_platform->getIntegerTypeDeclarationSql(array()) $this->_platform->getIntegerTypeDeclarationSQL(array())
); );
$this->assertEquals( $this->assertEquals(
'INTEGER AUTOINCREMENT', 'INTEGER AUTOINCREMENT',
$this->_platform->getIntegerTypeDeclarationSql(array('autoincrement' => true)) $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true))
); );
$this->assertEquals( $this->assertEquals(
'INTEGER PRIMARY KEY AUTOINCREMENT', 'INTEGER PRIMARY KEY AUTOINCREMENT',
$this->_platform->getIntegerTypeDeclarationSql( $this->_platform->getIntegerTypeDeclarationSQL(
array('autoincrement' => true, 'primary' => true)) array('autoincrement' => true, 'primary' => true))
); );
} }
...@@ -68,17 +68,17 @@ class SqlitePlatformTest extends AbstractPlatformTestCase ...@@ -68,17 +68,17 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
{ {
$this->assertEquals( $this->assertEquals(
'CHAR(10)', 'CHAR(10)',
$this->_platform->getVarcharTypeDeclarationSql( $this->_platform->getVarcharTypeDeclarationSQL(
array('length' => 10, 'fixed' => true)) array('length' => 10, 'fixed' => true))
); );
$this->assertEquals( $this->assertEquals(
'VARCHAR(50)', 'VARCHAR(50)',
$this->_platform->getVarcharTypeDeclarationSql(array('length' => 50)), $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)),
'Variable string declaration is not correct' 'Variable string declaration is not correct'
); );
$this->assertEquals( $this->assertEquals(
'TEXT', 'TEXT',
$this->_platform->getVarcharTypeDeclarationSql(array()), $this->_platform->getVarcharTypeDeclarationSQL(array()),
'Long string declaration is not correct' 'Long string declaration is not correct'
); );
} }
......
...@@ -35,31 +35,31 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform ...@@ -35,31 +35,31 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform
} }
/** @override */ /** @override */
public function getSequenceNextValSql($sequenceName) public function getSequenceNextValSQL($sequenceName)
{ {
return $this->_sequenceNextValSql; return $this->_sequenceNextValSql;
} }
/** @override */ /** @override */
public function getBooleanTypeDeclarationSql(array $field) {} public function getBooleanTypeDeclarationSQL(array $field) {}
/** @override */ /** @override */
public function getIntegerTypeDeclarationSql(array $field) {} public function getIntegerTypeDeclarationSQL(array $field) {}
/** @override */ /** @override */
public function getBigIntTypeDeclarationSql(array $field) {} public function getBigIntTypeDeclarationSQL(array $field) {}
/** @override */ /** @override */
public function getSmallIntTypeDeclarationSql(array $field) {} public function getSmallIntTypeDeclarationSQL(array $field) {}
/** @override */ /** @override */
protected function _getCommonIntegerTypeDeclarationSql(array $columnDef) {} protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef) {}
/** @override */ /** @override */
public function getVarcharTypeDeclarationSql(array $field) {} public function getVarcharTypeDeclarationSQL(array $field) {}
/** @override */ /** @override */
public function getClobTypeDeclarationSql(array $field) {} public function getClobTypeDeclarationSQL(array $field) {}
/* MOCK API */ /* MOCK API */
......
<?php
namespace Doctrine\Tests\ORM\Functional\Ticket;
require_once __DIR__ . '/../../../TestInit.php';
class DDC258Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
protected function setUp()
{
parent::setUp();
$this->_schemaTool->createSchema(array(
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC258Super'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC258Class1'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC258Class2'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC258Class3'),
));
}
/**
* @group DDC-258
*/
public function testIssue()
{
//$this->_em->getConnection()->getConfiguration()->setSqlLogger(new \Doctrine\DBAL\Logging\EchoSqlLogger);
$c1 = new DDC258Class1();
$c1->title = "Foo";
$c1->description = "Foo";
$c2 = new DDC258Class2();
$c2->title = "Bar";
$c2->description = "Bar";
$c2->text = "Bar";
$c3 = new DDC258Class3();
$c3->apples = "Baz";
$c3->bananas = "Baz";
$this->_em->persist($c1);
$this->_em->persist($c2);
$this->_em->persist($c3);
$this->_em->flush();
$this->_em->clear();
$e2 = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC258Super', $c2->id);
$this->assertType('Doctrine\Tests\ORM\Functional\Ticket\DDC258Class2', $e2);
$this->assertEquals('Bar', $e2->title);
$this->assertEquals('Bar', $e2->description);
$this->assertEquals('Bar', $e2->text);
$all = $this->_em->getRepository(__NAMESPACE__.'\DDC258Super')->findAll();
foreach ($all as $obj) {
if ($obj instanceof DDC258Class1) {
$this->assertEquals('Foo', $obj->title);
$this->assertEquals('Foo', $obj->description);
} else if ($obj instanceof DDC258Class2) {
$this->assertTrue($e2 === $obj);
$this->assertEquals('Bar', $obj->title);
$this->assertEquals('Bar', $obj->description);
$this->assertEquals('Bar', $obj->text);
} else if ($obj instanceof DDC258Class3) {
$this->assertEquals('Baz', $obj->apples);
$this->assertEquals('Baz', $obj->bananas);
} else {
$this->fail('Instance of DDC258Class1, DDC258Class2 or DDC258Class3 expected.');
}
}
}
}
/**
* @Entity
* @Table(name="DDC258Super")
* @InheritanceType("JOINED")
* @DiscriminatorColumn(name="type", type="string")
* @DiscriminatorMap({"class1" = "DDC258Class1", "class2" = "DDC258Class2", "class3"="DDC258Class3"})
*/
abstract class DDC258Super
{
/**
* @Id @Column(name="id", type="integer")
* @GeneratedValue(strategy="AUTO")
*/
public $id;
}
/**
* @Entity
*/
class DDC258Class1 extends DDC258Super
{
/**
* @Column(name="title", type="string", length="150")
*/
public $title;
/**
* @Column(name="content", type="string", length="500")
*/
public $description;
}
/**
* @Entity
*/
class DDC258Class2 extends DDC258Super
{
/**
* @Column(name="title", type="string", length="150")
*/
public $title;
/**
* @Column(name="content", type="string", length="500")
*/
public $description;
/**
* @Column(name="text", type="text")
*/
public $text;
}
/**
* An extra class to demonstrate why title and description aren't in Super
*
* @Entity
*/
class DDC258Class3 extends DDC258Super
{
/**
* @Column(name="title", type="string", length="150")
*/
public $apples;
/**
* @Column(name="content", type="string", length="500")
*/
public $bananas;
}
\ No newline at end of file
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
namespace Doctrine\Tests\ORM\Query; namespace Doctrine\Tests\ORM\Query;
use Doctrine\ORM\Query, use Doctrine\ORM\Query;
Doctrine\Common\DoctrineException;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
......
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