Commit 79805d69 authored by Kim Hemsø Rasmussen's avatar Kim Hemsø Rasmussen

Merge branch 'master' into drizzle

parents 035b079c 4cb8a99b
......@@ -584,7 +584,7 @@ class Connection implements DriverConnection
* Prepares an SQL statement.
*
* @param string $statement The SQL statement to prepare.
* @return Doctrine\DBAL\Driver\Statement The prepared statement.
* @return \Doctrine\DBAL\Driver\Statement The prepared statement.
*/
public function prepare($statement)
{
......@@ -603,7 +603,7 @@ class Connection implements DriverConnection
* @param array $params The parameters to bind to the query, if any.
* @param array $types The types the previous parameters are in.
* @param QueryCacheProfile $qcp
* @return Doctrine\DBAL\Driver\Statement The executed statement.
* @return \Doctrine\DBAL\Driver\Statement The executed statement.
* @internal PERF: Directly prepares a driver statement, not a wrapper.
*/
public function executeQuery($query, array $params = array(), $types = array(), QueryCacheProfile $qcp = null)
......@@ -700,7 +700,7 @@ class Connection implements DriverConnection
*
* @param string $statement
* @param integer $fetchType
* @return Doctrine\DBAL\Driver\Statement
* @return \Doctrine\DBAL\Driver\Statement
*/
public function query()
{
......@@ -1015,7 +1015,7 @@ class Connection implements DriverConnection
/**
* Gets the wrapped driver connection.
*
* @return Doctrine\DBAL\Driver\Connection
* @return \Doctrine\DBAL\Driver\Connection
*/
public function getWrappedConnection()
{
......@@ -1028,7 +1028,7 @@ class Connection implements DriverConnection
* Gets the SchemaManager that can be used to inspect or change the
* database schema through the connection.
*
* @return Doctrine\DBAL\Schema\AbstractSchemaManager
* @return \Doctrine\DBAL\Schema\AbstractSchemaManager
*/
public function getSchemaManager()
{
......
......@@ -34,7 +34,7 @@ interface Driver
* @param string $username The username to use when connecting.
* @param string $password The password to use when connecting.
* @param array $driverOptions The driver options to use when connecting.
* @return Doctrine\DBAL\Driver\Connection The database connection.
* @return \Doctrine\DBAL\Driver\Connection The database connection.
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array());
......@@ -42,7 +42,7 @@ interface Driver
* Gets the DatabasePlatform instance that provides all the metadata about
* the platform this driver connects to.
*
* @return Doctrine\DBAL\Platforms\AbstractPlatform The database platform.
* @return \Doctrine\DBAL\Platforms\AbstractPlatform The database platform.
*/
public function getDatabasePlatform();
......@@ -50,8 +50,8 @@ interface Driver
* Gets the SchemaManager that can be used to inspect and change the underlying
* database schema of the platform this driver connects to.
*
* @param Doctrine\DBAL\Connection $conn
* @return Doctrine\DBAL\SchemaManager
* @param \Doctrine\DBAL\Connection $conn
* @return \Doctrine\DBAL\SchemaManager
*/
public function getSchemaManager(Connection $conn);
......@@ -65,7 +65,7 @@ interface Driver
/**
* Get the name of the database connected to for this driver.
*
* @param Doctrine\DBAL\Connection $conn
* @param \Doctrine\DBAL\Connection $conn
* @return string $database
*/
public function getDatabase(Connection $conn);
......
......@@ -37,7 +37,7 @@ class DB2Driver implements Driver
* @param string $username The username to use when connecting.
* @param string $password The password to use when connecting.
* @param array $driverOptions The driver options to use when connecting.
* @return Doctrine\DBAL\Driver\Connection The database connection.
* @return \Doctrine\DBAL\Driver\Connection The database connection.
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
......@@ -65,7 +65,7 @@ class DB2Driver implements Driver
* Gets the DatabasePlatform instance that provides all the metadata about
* the platform this driver connects to.
*
* @return Doctrine\DBAL\Platforms\AbstractPlatform The database platform.
* @return \Doctrine\DBAL\Platforms\AbstractPlatform The database platform.
*/
public function getDatabasePlatform()
{
......@@ -76,8 +76,8 @@ class DB2Driver implements Driver
* Gets the SchemaManager that can be used to inspect and change the underlying
* database schema of the platform this driver connects to.
*
* @param Doctrine\DBAL\Connection $conn
* @return Doctrine\DBAL\SchemaManager
* @param \Doctrine\DBAL\Connection $conn
* @return \Doctrine\DBAL\SchemaManager
*/
public function getSchemaManager(Connection $conn)
{
......@@ -97,7 +97,7 @@ class DB2Driver implements Driver
/**
* Get the name of the database connected to for this driver.
*
* @param Doctrine\DBAL\Connection $conn
* @param \Doctrine\DBAL\Connection $conn
* @return string $database
*/
public function getDatabase(\Doctrine\DBAL\Connection $conn)
......
......@@ -44,7 +44,7 @@ class Driver implements \Doctrine\DBAL\Driver
* @param string $username
* @param string $password
* @param array $driverOptions
* @return Doctrine\DBAL\Driver\Connection
* @return \Doctrine\DBAL\Driver\Connection
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
......@@ -83,7 +83,7 @@ class Driver implements \Doctrine\DBAL\Driver
* Gets the DatabasePlatform instance that provides all the metadata about
* the platform this driver connects to.
*
* @return Doctrine\DBAL\Platforms\AbstractPlatform The database platform.
* @return \Doctrine\DBAL\Platforms\AbstractPlatform The database platform.
*/
public function getDatabasePlatform()
{
......@@ -94,8 +94,8 @@ class Driver implements \Doctrine\DBAL\Driver
* Gets the SchemaManager that can be used to inspect and change the underlying
* database schema of the platform this driver connects to.
*
* @param Doctrine\DBAL\Connection $conn
* @return Doctrine\DBAL\SchemaManager
* @param \Doctrine\DBAL\Connection $conn
* @return \Doctrine\DBAL\SchemaManager
*/
public function getSchemaManager(Connection $conn)
{
......@@ -115,7 +115,7 @@ class Driver implements \Doctrine\DBAL\Driver
/**
* Get the name of the database connected to for this driver.
*
* @param Doctrine\DBAL\Connection $conn
* @param \Doctrine\DBAL\Connection $conn
* @return string $database
*/
public function getDatabase(\Doctrine\DBAL\Connection $conn)
......
......@@ -35,7 +35,7 @@ class Driver implements \Doctrine\DBAL\Driver
* @param string $username
* @param string $password
* @param array $driverOptions
* @return Doctrine\DBAL\Driver\Connection
* @return \Doctrine\DBAL\Driver\Connection
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
......
......@@ -14,7 +14,7 @@ class Driver implements \Doctrine\DBAL\Driver
/**
* Attempts to connect to the database and returns a driver connection on success.
*
* @return Doctrine\DBAL\Driver\Connection
* @return \Doctrine\DBAL\Driver\Connection
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
......
......@@ -95,8 +95,8 @@ class Driver implements \Doctrine\DBAL\Driver
/**
* Gets the schema manager that is relevant for this driver.
*
* @param Doctrine\DBAL\Connection $conn
* @return Doctrine\DBAL\Schema\SqliteSchemaManager
* @param \Doctrine\DBAL\Connection $conn
* @return \Doctrine\DBAL\Schema\SqliteSchemaManager
*/
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
{
......
......@@ -92,9 +92,9 @@ final class DriverManager
* The driver class to use.
*
* @param array $params The parameters.
* @param Doctrine\DBAL\Configuration The configuration to use.
* @param Doctrine\Common\EventManager The event manager to use.
* @return Doctrine\DBAL\Connection
* @param \Doctrine\DBAL\Configuration The configuration to use.
* @param \Doctrine\Common\EventManager The event manager to use.
* @return \Doctrine\DBAL\Connection
*/
public static function getConnection(
array $params,
......
......@@ -46,7 +46,7 @@ class ConnectionEventArgs extends EventArgs
}
/**
* @return Doctrine\DBAL\Connection
* @return \Doctrine\DBAL\Connection
*/
public function getConnection()
{
......@@ -54,7 +54,7 @@ class ConnectionEventArgs extends EventArgs
}
/**
* @return Doctrine\DBAL\Driver
* @return \Doctrine\DBAL\Driver
*/
public function getDriver()
{
......@@ -62,7 +62,7 @@ class ConnectionEventArgs extends EventArgs
}
/**
* @return Doctrine\DBAL\Platforms\AbstractPlatform
* @return \Doctrine\DBAL\Platforms\AbstractPlatform
*/
public function getDatabasePlatform()
{
......@@ -70,7 +70,7 @@ class ConnectionEventArgs extends EventArgs
}
/**
* @return Doctrine\DBAL\Schema\AbstractSchemaManager
* @return \Doctrine\DBAL\Schema\AbstractSchemaManager
*/
public function getSchemaManager()
{
......
......@@ -61,7 +61,7 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs
* @param \Doctrine\DBAL\Schema\Table $table
* @param array $columns
* @param array $options
* @param Doctrine\DBAL\Platforms\AbstractPlatform $platform
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
*/
public function __construct(Table $table, array $columns, array $options, AbstractPlatform $platform)
{
......
......@@ -1095,7 +1095,7 @@ abstract class AbstractPlatform
$sql = $this->_getCreateTableSQL($tableName, $columns, $options);
if ($this->supportsCommentOnStatement()) {
foreach ($table->getColumns() AS $column) {
if ($column->getComment()) {
if ($this->getColumnComment($column)) {
$sql[] = $this->getCommentOnColumnSQL($tableName, $column->getName(), $this->getColumnComment($column));
}
}
......@@ -1276,7 +1276,8 @@ abstract class AbstractPlatform
/**
* Quotes a string so that it can be safely used as a table or column name,
* even if it is a reserved word of the platform.
* even if it is a reserved word of the platform. This also detects identifier
* chains seperated by dot and quotes them independently.
*
* NOTE: Just because you CAN use quoted identifiers doesn't mean
* you SHOULD use them. In general, they end up causing way more
......@@ -1286,6 +1287,22 @@ abstract class AbstractPlatform
* @return string quoted identifier string
*/
public function quoteIdentifier($str)
{
if (strpos($str, ".") !== false) {
$parts = array_map(array($this, "quoteIdentifier"), explode(".", $str));
return implode(".", $parts);
}
return $this->quoteSingleIdentifier($str);
}
/**
* Quote a single identifier (no dot chain seperation)
*
* @param string $str
* @return string
*/
public function quoteSingleIdentifier($str)
{
$c = $this->getIdentifierQuoteCharacter();
......
......@@ -831,17 +831,9 @@ class MsSqlPlatform extends AbstractPlatform
}
/**
* Quotes a string so that it can be safely used as a table or column name,
* even if it is a reserved word of the platform.
*
* NOTE: Just because you CAN use quoted identifiers doesn't mean
* you SHOULD use them. In general, they end up causing way more
* problems than they solve.
*
* @param string $str identifier name to be quoted
* @return string quoted identifier string
* {@inheritDoc}
*/
public function quoteIdentifier($str)
public function quoteSingleIdentifier($str)
{
return "[" . str_replace("]", "][", $str) . "]";
}
......
......@@ -99,7 +99,7 @@ class Connection extends \Doctrine\DBAL\Connection
* Prepares an SQL statement.
*
* @param string $statement The SQL statement to prepare.
* @return Doctrine\DBAL\Driver\Statement The prepared statement.
* @return \Doctrine\DBAL\Driver\Statement The prepared statement.
*/
public function prepare($statement)
{
......
......@@ -56,8 +56,8 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
/**
* Wraps <tt>Statement</tt> and applies portability measures
*
* @param Doctrine\DBAL\Driver\Statement $stmt
* @param Doctrine\DBAL\Connection $conn
* @param \Doctrine\DBAL\Driver\Statement $stmt
* @param \Doctrine\DBAL\Connection $conn
*/
public function __construct($stmt, Connection $conn)
{
......
......@@ -47,7 +47,7 @@ class ExpressionBuilder
/**
* Initializes a new <tt>ExpressionBuilder</tt>.
*
* @param Doctrine\DBAL\Connection $connection DBAL Connection
* @param \Doctrine\DBAL\Connection $connection DBAL Connection
*/
public function __construct(Connection $connection)
{
......
......@@ -113,7 +113,7 @@ class QueryBuilder
/**
* Initializes a new <tt>QueryBuilder</tt>.
*
* @param Doctrine\DBAL\Connection $connection DBAL Connection
* @param \Doctrine\DBAL\Connection $connection DBAL Connection
*/
public function __construct(Connection $connection)
{
......@@ -134,7 +134,7 @@ class QueryBuilder
* For more complex expression construction, consider storing the expression
* builder object in a local variable.
*
* @return Doctrine\DBAL\Query\ExpressionBuilder
* @return \Doctrine\DBAL\Query\ExpressionBuilder
*/
public function expr()
{
......@@ -154,7 +154,7 @@ class QueryBuilder
/**
* Get the associated DBAL Connection for this query builder.
*
* @return Doctrine\DBAL\Connection
* @return \Doctrine\DBAL\Connection
*/
public function getConnection()
{
......@@ -306,7 +306,7 @@ class QueryBuilder
* Sets the position of the first result to retrieve (the "offset").
*
* @param integer $firstResult The first result to return.
* @return Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance.
* @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance.
*/
public function setFirstResult($firstResult)
{
......@@ -330,7 +330,7 @@ class QueryBuilder
* Sets the maximum number of results to retrieve (the "limit").
*
* @param integer $maxResults The maximum number of results to retrieve.
* @return Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance.
* @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance.
*/
public function setMaxResults($maxResults)
{
......@@ -359,7 +359,7 @@ class QueryBuilder
* @param string $sqlPartName
* @param string $sqlPart
* @param string $append
* @return Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance.
* @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance.
*/
public function add($sqlPartName, $sqlPart, $append = false)
{
......
......@@ -830,7 +830,7 @@ abstract class AbstractSchemaManager
*/
public function extractDoctrineTypeFromComment($comment, $currentType)
{
if (preg_match("(\(DC2Type:([a-zA-Z0-9]+)\))", $comment, $match)) {
if (preg_match("(\(DC2Type:([a-zA-Z0-9_]+)\))", $comment, $match)) {
$currentType = $match[1];
}
return $currentType;
......
......@@ -102,7 +102,7 @@ class Column extends AbstractAsset
* Create a new Column
*
* @param string $columnName
* @param Doctrine\DBAL\Types\Type $type
* @param \Doctrine\DBAL\Types\Type $type
* @param int $length
* @param bool $notNull
* @param mixed $default
......
......@@ -156,7 +156,7 @@ class Schema extends AbstractAsset
/**
* @throws SchemaException
* @param string $sequenceName
* @return Doctrine\DBAL\Schema\Sequence
* @return \Doctrine\DBAL\Schema\Sequence
*/
public function getSequence($sequenceName)
{
......@@ -168,7 +168,7 @@ class Schema extends AbstractAsset
}
/**
* @return Doctrine\DBAL\Schema\Sequence[]
* @return \Doctrine\DBAL\Schema\Sequence[]
*/
public function getSequences()
{
......
......@@ -59,7 +59,7 @@ class Statement implements \IteratorAggregate, DriverStatement
* Creates a new <tt>Statement</tt> for the given SQL and <tt>Connection</tt>.
*
* @param string $sql The SQL of the statement.
* @param Doctrine\DBAL\Connection The connection on which the statement should be executed.
* @param \Doctrine\DBAL\Connection The connection on which the statement should be executed.
*/
public function __construct($sql, Connection $conn)
{
......@@ -238,7 +238,7 @@ class Statement implements \IteratorAggregate, DriverStatement
/**
* Gets the wrapped driver statement.
*
* @return Doctrine\DBAL\Driver\Statement
* @return \Doctrine\DBAL\Driver\Statement
*/
public function getWrappedStatement()
{
......
......@@ -133,7 +133,7 @@ abstract class Type
* @static
* @throws DBALException
* @param string $name The name of the type (as returned by getName()).
* @return Doctrine\DBAL\Types\Type
* @return \Doctrine\DBAL\Types\Type
*/
public static function getType($name)
{
......@@ -190,6 +190,10 @@ abstract class Type
throw DBALException::typeNotFound($name);
}
if (isset(self::$_typeObjects[$name])) {
unset(self::$_typeObjects[$name]);
}
self::$_typesMap[$name] = $className;
}
......
......@@ -19,6 +19,9 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this->_platform = $this->createPlatform();
}
/**
* @group DDC-1360
*/
public function testQuoteIdentifier()
{
if ($this->_platform->getName() == "mssql") {
......@@ -26,9 +29,26 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
}
$c = $this->_platform->getIdentifierQuoteCharacter();
$this->assertEquals($c."test".$c, $this->_platform->quoteIdentifier("test"));
$this->assertEquals($c."test".$c.".".$c."test".$c, $this->_platform->quoteIdentifier("test.test"));
$this->assertEquals(str_repeat($c, 4), $this->_platform->quoteIdentifier($c));
}
/**
* @group DDC-1360
*/
public function testQuoteSingleIdentifier()
{
if ($this->_platform->getName() == "mssql") {
$this->markTestSkipped('Not working this way on mssql.');
}
$c = $this->_platform->getIdentifierQuoteCharacter();
$this->assertEquals($c."test".$c, $this->_platform->quoteSingleIdentifier("test"));
$this->assertEquals($c."test.test".$c, $this->_platform->quoteSingleIdentifier("test.test"));
$this->assertEquals(str_repeat($c, 4), $this->_platform->quoteSingleIdentifier($c));
}
public function testGetInvalidtForeignKeyReferentialActionSQL()
{
$this->setExpectedException('InvalidArgumentException');
......@@ -326,6 +346,16 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this->assertEquals($this->getAlterTableColumnCommentsSQL(), $this->_platform->getAlterTableSQL($tableDiff));
}
public function testCreateTableColumnTypeComments()
{
$table = new \Doctrine\DBAL\Schema\Table('test');
$table->addColumn('id', 'integer');
$table->addColumn('data', 'array');
$table->setPrimaryKey(array('id'));
$this->assertEquals($this->getCreateTableColumnTypeCommentsSQL(), $this->_platform->getCreateTableSQL($table));
}
public function getCreateTableColumnCommentsSQL()
{
$this->markTestSkipped('Platform does not support Column comments.');
......@@ -336,6 +366,11 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this->markTestSkipped('Platform does not support Column comments.');
}
public function getCreateTableColumnTypeCommentsSQL()
{
$this->markTestSkipped('Platform does not support Column comments.');
}
/**
* @group DBAL-45
*/
......
......@@ -171,8 +171,23 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase
$this->assertEquals('SELECT TOP 10 * FROM user ORDER BY username DESC', $sql);
}
/**
* @group DDC-1360
*/
public function testQuoteIdentifier()
{
$this->assertEquals('[fo][o]', $this->_platform->quoteIdentifier('fo]o'));
$this->assertEquals('[test]', $this->_platform->quoteIdentifier('test'));
$this->assertEquals('[test].[test]', $this->_platform->quoteIdentifier('test.test'));
}
/**
* @group DDC-1360
*/
public function testQuoteSingleIdentifier()
{
$this->assertEquals('[fo][o]', $this->_platform->quoteSingleIdentifier('fo]o'));
$this->assertEquals('[test]', $this->_platform->quoteSingleIdentifier('test'));
$this->assertEquals('[test.test]', $this->_platform->quoteSingleIdentifier('test.test'));
}
}
......@@ -204,4 +204,9 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
{
return array("ALTER TABLE mytable ADD quota INT NOT NULL COMMENT 'A comment', CHANGE bar baz VARCHAR(255) NOT NULL COMMENT 'B comment'");
}
public function getCreateTableColumnTypeCommentsSQL()
{
return array("CREATE TABLE test (id INT NOT NULL, data LONGTEXT NOT NULL COMMENT '(DC2Type:array)', PRIMARY KEY(id)) ENGINE = InnoDB");
}
}
\ No newline at end of file
......@@ -195,6 +195,14 @@ class OraclePlatformTest extends AbstractPlatformTestCase
);
}
public function getCreateTableColumnTypeCommentsSQL()
{
return array(
"CREATE TABLE test (id NUMBER(10) NOT NULL, data CLOB NOT NULL, PRIMARY KEY(id))",
"COMMENT ON COLUMN test.data IS '(DC2Type:array)'"
);
}
public function getAlterTableColumnCommentsSQL()
{
return array(
......
......@@ -216,4 +216,12 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
"COMMENT ON COLUMN mytable.baz IS 'B comment'",
);
}
public function getCreateTableColumnTypeCommentsSQL()
{
return array(
"CREATE TABLE test (id INT NOT NULL, data TEXT NOT NULL, PRIMARY KEY(id))",
"COMMENT ON COLUMN test.data IS '(DC2Type:array)'"
);
}
}
\ No newline at end of file
......@@ -28,7 +28,7 @@ class TestUtil
* 1) Each invocation of this method returns a NEW database connection.
* 2) The database is dropped and recreated to ensure it's clean.
*
* @return Doctrine\DBAL\Connection The database connection instance.
* @return \Doctrine\DBAL\Connection The database connection instance.
*/
public static function getConnection()
{
......
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