Automated coding style fixes using phpcbf

parent a84752c4
......@@ -44,25 +44,16 @@ final class ArrayStatement implements IteratorAggregate, ResultStatement
$this->columnCount = count($data[0]);
}
/**
* {@inheritdoc}
*/
public function closeCursor() : void
{
$this->data = [];
}
/**
* {@inheritdoc}
*/
public function columnCount() : int
{
return $this->columnCount;
}
/**
* {@inheritdoc}
*/
public function rowCount() : int
{
return count($this->data);
......
......@@ -69,9 +69,6 @@ final class ResultCacheStatement implements IteratorAggregate, ResultStatement
$this->lifetime = $lifetime;
}
/**
* {@inheritdoc}
*/
public function closeCursor() : void
{
$this->statement->closeCursor();
......@@ -84,15 +81,13 @@ final class ResultCacheStatement implements IteratorAggregate, ResultStatement
if (! $data) {
$data = [];
}
$data[$this->realKey] = $this->data;
$this->resultCache->save($this->cacheKey, $data, $this->lifetime);
unset($this->data);
}
/**
* {@inheritdoc}
*/
public function columnCount() : int
{
return $this->statement->columnCount();
......
......@@ -731,9 +731,6 @@ class Connection implements DriverConnection
return $this->getDatabasePlatform()->quoteIdentifier($identifier);
}
/**
* {@inheritDoc}
*/
public function quote(string $input) : string
{
return $this->getWrappedConnection()->quote($input);
......@@ -872,9 +869,6 @@ class Connection implements DriverConnection
return $stmt;
}
/**
* {@inheritDoc}
*/
public function query(string $sql) : ResultStatement
{
$connection = $this->getWrappedConnection();
......@@ -926,6 +920,7 @@ class Connection implements DriverConnection
} else {
$stmt->execute($params);
}
$result = $stmt->rowCount();
} else {
$result = $connection->exec($query);
......@@ -939,9 +934,6 @@ class Connection implements DriverConnection
return $result;
}
/**
* {@inheritDoc}
*/
public function exec(string $statement) : int
{
$connection = $this->getWrappedConnection();
......@@ -1011,6 +1003,7 @@ class Connection implements DriverConnection
return $res;
} catch (Throwable $e) {
$this->rollBack();
throw $e;
}
}
......@@ -1052,9 +1045,6 @@ class Connection implements DriverConnection
return 'DOCTRINE2_SAVEPOINT_' . $this->transactionNestingLevel;
}
/**
* {@inheritDoc}
*/
public function beginTransaction() : void
{
$connection = $this->getWrappedConnection();
......@@ -1089,6 +1079,7 @@ class Connection implements DriverConnection
if ($this->transactionNestingLevel === 0) {
throw NoActiveTransaction::new();
}
if ($this->isRollbackOnly) {
throw CommitFailedRollbackOnly::new();
}
......@@ -1271,6 +1262,7 @@ class Connection implements DriverConnection
if ($this->transactionNestingLevel === 0) {
throw NoActiveTransaction::new();
}
$this->isRollbackOnly = true;
}
......@@ -1343,6 +1335,7 @@ class Connection implements DriverConnection
} else {
$stmt->bindValue($bindIndex, $value);
}
++$bindIndex;
}
} else {
......@@ -1372,6 +1365,7 @@ class Connection implements DriverConnection
if (is_string($type)) {
$type = Type::getType($type);
}
if ($type instanceof Type) {
$value = $type->convertToDatabaseValue($value, $this->getDatabasePlatform());
$bindingType = $type->getBindingType();
......@@ -1411,6 +1405,7 @@ class Connection implements DriverConnection
} else {
$resolvedParams[$bindIndex] = $value;
}
++$bindIndex;
}
} else {
......
......@@ -103,6 +103,7 @@ class MasterSlaveConnection extends Connection
if (! isset($params['slaves'], $params['master'])) {
throw new InvalidArgumentException('master or slaves configuration missing');
}
if (count($params['slaves']) === 0) {
throw new InvalidArgumentException('You have to configure at least one slaves.');
}
......@@ -227,9 +228,6 @@ class MasterSlaveConnection extends Connection
return parent::executeUpdate($query, $params, $types);
}
/**
* {@inheritDoc}
*/
public function beginTransaction() : void
{
$this->connect('master');
......@@ -237,9 +235,6 @@ class MasterSlaveConnection extends Connection
parent::beginTransaction();
}
/**
* {@inheritDoc}
*/
public function commit() : void
{
$this->connect('master');
......@@ -247,9 +242,6 @@ class MasterSlaveConnection extends Connection
parent::commit();
}
/**
* {@inheritDoc}
*/
public function rollBack() : void
{
$this->connect('master');
......@@ -267,9 +259,6 @@ class MasterSlaveConnection extends Connection
return parent::delete($table, $identifier, $types);
}
/**
* {@inheritDoc}
*/
public function close() : void
{
unset($this->connections['master'], $this->connections['slave']);
......@@ -300,9 +289,6 @@ class MasterSlaveConnection extends Connection
return parent::insert($table, $data, $types);
}
/**
* {@inheritDoc}
*/
public function exec(string $statement) : int
{
$this->connect('master');
......@@ -310,9 +296,6 @@ class MasterSlaveConnection extends Connection
return parent::exec($statement);
}
/**
* {@inheritDoc}
*/
public function createSavepoint(string $savepoint) : void
{
$this->connect('master');
......@@ -320,9 +303,6 @@ class MasterSlaveConnection extends Connection
parent::createSavepoint($savepoint);
}
/**
* {@inheritDoc}
*/
public function releaseSavepoint(string $savepoint) : void
{
$this->connect('master');
......@@ -330,9 +310,6 @@ class MasterSlaveConnection extends Connection
parent::releaseSavepoint($savepoint);
}
/**
* {@inheritDoc}
*/
public function rollbackSavepoint(string $savepoint) : void
{
$this->connect('master');
......@@ -340,9 +317,6 @@ class MasterSlaveConnection extends Connection
parent::rollbackSavepoint($savepoint);
}
/**
* {@inheritDoc}
*/
public function query(string $sql) : ResultStatement
{
$this->connect('master');
......@@ -360,9 +334,6 @@ class MasterSlaveConnection extends Connection
return $statement;
}
/**
* {@inheritDoc}
*/
public function prepare(string $sql) : Statement
{
$this->connect('master');
......
......@@ -51,6 +51,7 @@ MESSAGE;
if ($driverEx instanceof DriverException) {
return $driverEx;
}
if ($driver instanceof ExceptionConverterDriver && $driverEx instanceof DriverExceptionInterface) {
return $driver->convertException($msg, $driverEx);
}
......
......@@ -16,17 +16,11 @@ use Doctrine\DBAL\Schema\DB2SchemaManager;
*/
abstract class AbstractDB2Driver implements Driver
{
/**
* {@inheritdoc}
*/
public function getDatabasePlatform() : AbstractPlatform
{
return new DB2Platform();
}
/**
* {@inheritdoc}
*/
public function getSchemaManager(Connection $conn) : AbstractSchemaManager
{
return new DB2SchemaManager($conn);
......
......@@ -32,9 +32,6 @@ abstract class AbstractDriverException extends Exception implements DriverExcept
$this->sqlState = $sqlState;
}
/**
* {@inheritdoc}
*/
public function getSQLState() : ?string
{
return $this->sqlState;
......
......@@ -93,9 +93,6 @@ abstract class AbstractMySQLDriver implements ExceptionConverterDriver, VersionA
private const CR_UNKNOWN_HOST = 2005;
/**#@-*/
/**
* {@inheritdoc}
*/
public function convertException(string $message, DriverExceptionInterface $exception) : DriverException
{
switch ($exception->getCode()) {
......@@ -105,34 +102,28 @@ abstract class AbstractMySQLDriver implements ExceptionConverterDriver, VersionA
return new Exception\LockWaitTimeoutException($message, $exception);
case self::ER_TABLE_EXISTS_ERROR:
return new Exception\TableExistsException($message, $exception);
case self::ER_BAD_TABLE_ERROR:
case self::ER_NO_SUCH_TABLE:
return new Exception\TableNotFoundException($message, $exception);
case self::ER_NO_REFERENCED_ROW:
case self::ER_ROW_IS_REFERENCED:
case self::ER_ROW_IS_REFERENCED_2:
case self::ER_NO_REFERENCED_ROW_2:
case self::ER_TRUNCATE_ILLEGAL_FK:
return new Exception\ForeignKeyConstraintViolationException($message, $exception);
case self::ER_DUP_ENTRY:
case self::ER_FOREIGN_DUPLICATE_KEY_OLD_UNUSED:
case self::ER_DUP_ENTRY_AUTOINCREMENT_CASE:
case self::ER_DUP_ENTRY_WITH_KEY_NAME:
return new Exception\UniqueConstraintViolationException($message, $exception);
case self::ER_BAD_FIELD_ERROR:
case self::ER_WRONG_COLUMN_NAME:
case self::ER_LOAD_DATA_INVALID_COLUMN:
return new Exception\InvalidFieldNameException($message, $exception);
case self::ER_NON_UNIQ_ERROR:
case self::ER_DUP_FIELDNAME:
case self::ER_FIELD_SPECIFIED_TWICE:
return new Exception\NonUniqueFieldNameException($message, $exception);
case self::ER_PARSE_ERROR:
case self::ER_SYNTAX_ERROR:
case self::ER_WARN_DEPRECATED_SYNTAX:
......@@ -146,7 +137,6 @@ abstract class AbstractMySQLDriver implements ExceptionConverterDriver, VersionA
case self::ER_WARN_DEPRECATED_SYNTAX_WITH_VER:
case self::ER_CONFLICT_FN_PARSE_ERROR:
return new Exception\SyntaxErrorException($message, $exception);
case self::ER_DBACCESS_DENIED_ERROR:
case self::ER_ACCESS_DENIED_ERROR:
case self::ER_NO_DB_ERROR:
......@@ -160,7 +150,6 @@ abstract class AbstractMySQLDriver implements ExceptionConverterDriver, VersionA
case self::CR_CONNECTION_ERROR:
case self::CR_UNKNOWN_HOST:
return new Exception\ConnectionException($message, $exception);
case self::ER_BAD_NULL_ERROR:
case self::ER_NULL_COLUMN_IN_INDEX:
case self::ER_INVALID_USE_OF_NULL:
......@@ -192,6 +181,7 @@ abstract class AbstractMySQLDriver implements ExceptionConverterDriver, VersionA
if (version_compare($oracleMysqlVersion, '8', '>=')) {
return new MySQL80Platform();
}
if (version_compare($oracleMysqlVersion, '5.7.9', '>=')) {
return new MySQL57Platform();
}
......@@ -220,6 +210,7 @@ abstract class AbstractMySQLDriver implements ExceptionConverterDriver, VersionA
'<major_version>.<minor_version>.<patch_version>'
);
}
$majorVersion = $versionParts['major'];
$minorVersion = $versionParts['minor'] ?? 0;
$patchVersion = $versionParts['patch'] ?? null;
......
......@@ -20,9 +20,6 @@ use Doctrine\DBAL\Schema\OracleSchemaManager;
*/
abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver
{
/**
* {@inheritdoc}
*/
public function convertException(string $message, DriverExceptionInterface $exception) : DriverException
{
switch ($exception->getCode()) {
......@@ -30,30 +27,22 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver
case 2299:
case 38911:
return new Exception\UniqueConstraintViolationException($message, $exception);
case 904:
return new Exception\InvalidFieldNameException($message, $exception);
case 918:
case 960:
return new Exception\NonUniqueFieldNameException($message, $exception);
case 923:
return new Exception\SyntaxErrorException($message, $exception);
case 942:
return new Exception\TableNotFoundException($message, $exception);
case 955:
return new Exception\TableExistsException($message, $exception);
case 1017:
case 12545:
return new Exception\ConnectionException($message, $exception);
case 1400:
return new Exception\NotNullConstraintViolationException($message, $exception);
case 2266:
case 2291:
case 2292:
......@@ -63,17 +52,11 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver
return new DriverException($message, $exception);
}
/**
* {@inheritdoc}
*/
public function getDatabasePlatform() : AbstractPlatform
{
return new OraclePlatform();
}
/**
* {@inheritdoc}
*/
public function getSchemaManager(Connection $conn) : AbstractSchemaManager
{
return new OracleSchemaManager($conn);
......
......@@ -45,25 +45,18 @@ abstract class AbstractPostgreSQLDriver implements ExceptionConverterDriver, Ver
break;
case '23502':
return new Exception\NotNullConstraintViolationException($message, $exception);
case '23503':
return new Exception\ForeignKeyConstraintViolationException($message, $exception);
case '23505':
return new Exception\UniqueConstraintViolationException($message, $exception);
case '42601':
return new Exception\SyntaxErrorException($message, $exception);
case '42702':
return new Exception\NonUniqueFieldNameException($message, $exception);
case '42703':
return new Exception\InvalidFieldNameException($message, $exception);
case '42P01':
return new Exception\TableNotFoundException($message, $exception);
case '42P07':
return new Exception\TableExistsException($message, $exception);
}
......@@ -78,9 +71,6 @@ abstract class AbstractPostgreSQLDriver implements ExceptionConverterDriver, Ver
return new DriverException($message, $exception);
}
/**
* {@inheritdoc}
*/
public function createDatabasePlatformForVersion(string $version) : AbstractPlatform
{
if (! preg_match('/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/', $version, $versionParts)) {
......@@ -102,17 +92,11 @@ abstract class AbstractPostgreSQLDriver implements ExceptionConverterDriver, Ver
return new PostgreSqlPlatform();
}
/**
* {@inheritdoc}
*/
public function getDatabasePlatform() : AbstractPlatform
{
return new PostgreSqlPlatform();
}
/**
* {@inheritdoc}
*/
public function getSchemaManager(Connection $conn) : AbstractSchemaManager
{
return new PostgreSqlSchemaManager($conn);
......
......@@ -66,9 +66,6 @@ abstract class AbstractSQLAnywhereDriver implements ExceptionConverterDriver, Ve
return new DriverException($message, $exception);
}
/**
* {@inheritdoc}
*/
public function createDatabasePlatformForVersion(string $version) : AbstractPlatform
{
if (! preg_match(
......@@ -88,17 +85,11 @@ abstract class AbstractSQLAnywhereDriver implements ExceptionConverterDriver, Ve
}
}
/**
* {@inheritdoc}
*/
public function getDatabasePlatform() : AbstractPlatform
{
return new SQLAnywherePlatform();
}
/**
* {@inheritdoc}
*/
public function getSchemaManager(Connection $conn) : AbstractSchemaManager
{
return new SQLAnywhereSchemaManager($conn);
......
......@@ -16,17 +16,11 @@ use Doctrine\DBAL\Schema\SQLServerSchemaManager;
*/
abstract class AbstractSQLServerDriver implements Driver
{
/**
* {@inheritdoc}
*/
public function getDatabasePlatform() : AbstractPlatform
{
return new SQLServerPlatform();
}
/**
* {@inheritdoc}
*/
public function getSchemaManager(Connection $conn) : AbstractSchemaManager
{
return new SQLServerSchemaManager($conn);
......
......@@ -80,17 +80,11 @@ abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver
return new DriverException($message, $exception);
}
/**
* {@inheritdoc}
*/
public function getDatabasePlatform() : AbstractPlatform
{
return new SqlitePlatform();
}
/**
* {@inheritdoc}
*/
public function getSchemaManager(Connection $conn) : AbstractSchemaManager
{
return new SqliteSchemaManager($conn);
......
......@@ -8,8 +8,7 @@ use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Driver\Statement as DriverStatement;
use stdClass;
use const DB2_AUTOCOMMIT_OFF;
use const DB2_AUTOCOMMIT_ON;
use function assert;
use function db2_autocommit;
use function db2_commit;
use function db2_connect;
......@@ -21,6 +20,8 @@ use function db2_pconnect;
use function db2_prepare;
use function db2_rollback;
use function db2_server_info;
use const DB2_AUTOCOMMIT_OFF;
use const DB2_AUTOCOMMIT_ON;
final class DB2Connection implements ServerInfoAwareConnection
{
......@@ -48,20 +49,14 @@ final class DB2Connection implements ServerInfoAwareConnection
$this->conn = $conn;
}
/**
* {@inheritdoc}
*/
public function getServerVersion() : string
{
/** @var stdClass $serverInfo */
$serverInfo = db2_server_info($this->conn);
assert($serverInfo instanceof stdClass);
return $serverInfo->DBMS_VER;
}
/**
* {@inheritdoc}
*/
public function prepare(string $sql) : DriverStatement
{
$stmt = @db2_prepare($this->conn, $sql);
......@@ -72,9 +67,6 @@ final class DB2Connection implements ServerInfoAwareConnection
return new DB2Statement($stmt);
}
/**
* {@inheritdoc}
*/
public function query(string $sql) : ResultStatement
{
$stmt = $this->prepare($sql);
......@@ -83,17 +75,11 @@ final class DB2Connection implements ServerInfoAwareConnection
return $stmt;
}
/**
* {@inheritdoc}
*/
public function quote(string $input) : string
{
return "'" . db2_escape_string($input) . "'";
}
/**
* {@inheritdoc}
*/
public function exec(string $statement) : int
{
$stmt = @db2_exec($this->conn, $statement);
......@@ -105,17 +91,11 @@ final class DB2Connection implements ServerInfoAwareConnection
return db2_num_rows($stmt);
}
/**
* {@inheritdoc}
*/
public function lastInsertId(?string $name = null) : string
{
return db2_last_insert_id($this->conn);
}
/**
* {@inheritdoc}
*/
public function beginTransaction() : void
{
if (! db2_autocommit($this->conn, DB2_AUTOCOMMIT_OFF)) {
......@@ -123,9 +103,6 @@ final class DB2Connection implements ServerInfoAwareConnection
}
}
/**
* {@inheritdoc}
*/
public function commit() : void
{
if (! db2_commit($this->conn)) {
......@@ -137,9 +114,6 @@ final class DB2Connection implements ServerInfoAwareConnection
}
}
/**
* {@inheritdoc}
*/
public function rollBack() : void
{
if (! db2_rollback($this->conn)) {
......
......@@ -14,12 +14,6 @@ use ReflectionClass;
use ReflectionObject;
use ReflectionProperty;
use stdClass;
use const CASE_LOWER;
use const DB2_BINARY;
use const DB2_CHAR;
use const DB2_LONG;
use const DB2_PARAM_FILE;
use const DB2_PARAM_IN;
use function array_change_key_case;
use function array_key_exists;
use function assert;
......@@ -47,6 +41,12 @@ use function stream_copy_to_stream;
use function stream_get_meta_data;
use function strtolower;
use function tmpfile;
use const CASE_LOWER;
use const DB2_BINARY;
use const DB2_CHAR;
use const DB2_LONG;
use const DB2_PARAM_FILE;
use const DB2_PARAM_IN;
final class DB2Statement implements IteratorAggregate, Statement
{
......@@ -128,9 +128,6 @@ final class DB2Statement implements IteratorAggregate, Statement
}
}
/**
* {@inheritdoc}
*/
public function closeCursor() : void
{
$this->bindParam = [];
......@@ -144,9 +141,6 @@ final class DB2Statement implements IteratorAggregate, Statement
$this->result = false;
}
/**
* {@inheritdoc}
*/
public function columnCount() : int
{
return db2_num_fields($this->stmt) ?: 0;
......@@ -233,13 +227,10 @@ final class DB2Statement implements IteratorAggregate, Statement
switch ($fetchMode) {
case FetchMode::COLUMN:
return $this->fetchColumn();
case FetchMode::MIXED:
return db2_fetch_both($this->stmt);
case FetchMode::ASSOCIATIVE:
return db2_fetch_assoc($this->stmt);
case FetchMode::CUSTOM_OBJECT:
$className = $this->defaultFetchClass;
$ctorArgs = $this->defaultFetchClassCtorArgs;
......@@ -256,13 +247,10 @@ final class DB2Statement implements IteratorAggregate, Statement
}
return $result;
case FetchMode::NUMERIC:
return db2_fetch_array($this->stmt);
case FetchMode::STANDARD_OBJECT:
return db2_fetch_object($this->stmt);
default:
throw new DB2Exception('Given Fetch-Style ' . $fetchMode . ' is not supported.');
}
......@@ -280,11 +268,13 @@ final class DB2Statement implements IteratorAggregate, Statement
while (($row = $this->fetch($fetchMode, ...$args)) !== false) {
$rows[] = $row;
}
break;
case FetchMode::COLUMN:
while (($row = $this->fetchColumn()) !== false) {
$rows[] = $row;
}
break;
default:
while (($row = $this->fetch($fetchMode)) !== false) {
......@@ -313,9 +303,6 @@ final class DB2Statement implements IteratorAggregate, Statement
return $row[$columnIndex];
}
/**
* {@inheritdoc}
*/
public function rowCount() : int
{
return @db2_num_rows($this->stmt) ? : 0;
......
......@@ -10,12 +10,6 @@ use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Driver\Statement as DriverStatement;
use mysqli;
use const MYSQLI_INIT_COMMAND;
use const MYSQLI_OPT_CONNECT_TIMEOUT;
use const MYSQLI_OPT_LOCAL_INFILE;
use const MYSQLI_READ_DEFAULT_FILE;
use const MYSQLI_READ_DEFAULT_GROUP;
use const MYSQLI_SERVER_PUBLIC_KEY;
use function defined;
use function floor;
use function in_array;
......@@ -26,6 +20,12 @@ use function restore_error_handler;
use function set_error_handler;
use function sprintf;
use function stripos;
use const MYSQLI_INIT_COMMAND;
use const MYSQLI_OPT_CONNECT_TIMEOUT;
use const MYSQLI_OPT_LOCAL_INFILE;
use const MYSQLI_READ_DEFAULT_FILE;
use const MYSQLI_READ_DEFAULT_GROUP;
use const MYSQLI_SERVER_PUBLIC_KEY;
class MysqliConnection implements PingableConnection, ServerInfoAwareConnection
{
......@@ -117,17 +117,11 @@ class MysqliConnection implements PingableConnection, ServerInfoAwareConnection
return $majorVersion . '.' . $minorVersion . '.' . $patchVersion;
}
/**
* {@inheritdoc}
*/
public function prepare(string $sql) : DriverStatement
{
return new MysqliStatement($this->conn, $sql);
}
/**
* {@inheritdoc}
*/
public function query(string $sql) : ResultStatement
{
$stmt = $this->prepare($sql);
......@@ -136,17 +130,11 @@ class MysqliConnection implements PingableConnection, ServerInfoAwareConnection
return $stmt;
}
/**
* {@inheritdoc}
*/
public function quote(string $input) : string
{
return "'" . $this->conn->escape_string($input) . "'";
}
/**
* {@inheritdoc}
*/
public function exec(string $statement) : int
{
if ($this->conn->query($statement) === false) {
......@@ -156,25 +144,16 @@ class MysqliConnection implements PingableConnection, ServerInfoAwareConnection
return $this->conn->affected_rows;
}
/**
* {@inheritdoc}
*/
public function lastInsertId(?string $name = null) : string
{
return (string) $this->conn->insert_id;
}
/**
* {@inheritdoc}
*/
public function beginTransaction() : void
{
$this->conn->query('START TRANSACTION');
}
/**
* {@inheritdoc}
*/
public function commit() : void
{
if (! $this->conn->commit()) {
......@@ -182,9 +161,6 @@ class MysqliConnection implements PingableConnection, ServerInfoAwareConnection
}
}
/**
* {@inheritdoc}
*/
public function rollBack() : void
{
if (! $this->conn->rollback()) {
......
......@@ -245,6 +245,7 @@ final class MysqliStatement implements IteratorAggregate, Statement
if (get_resource_type($value) !== 'stream') {
throw new InvalidArgumentException('Resources passed with the LARGE_OBJECT parameter type must be stream resources.');
}
$streams[$parameter] = $value;
$values[$parameter] = null;
continue;
......@@ -360,13 +361,10 @@ final class MysqliStatement implements IteratorAggregate, Statement
switch ($fetchMode) {
case FetchMode::ASSOCIATIVE:
return $assoc;
case FetchMode::MIXED:
return $assoc + $values;
case FetchMode::STANDARD_OBJECT:
return (object) $assoc;
default:
throw UnknownFetchMode::new($fetchMode);
}
......@@ -412,18 +410,12 @@ final class MysqliStatement implements IteratorAggregate, Statement
return $row[$columnIndex];
}
/**
* {@inheritdoc}
*/
public function closeCursor() : void
{
$this->stmt->free_result();
$this->result = false;
}
/**
* {@inheritdoc}
*/
public function rowCount() : int
{
if ($this->hasColumns) {
......@@ -433,9 +425,6 @@ final class MysqliStatement implements IteratorAggregate, Statement
return $this->stmt->affected_rows;
}
/**
* {@inheritdoc}
*/
public function columnCount() : int
{
return $this->stmt->field_count;
......
......@@ -4,12 +4,12 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\OCI8;
use const PREG_OFFSET_CAPTURE;
use function count;
use function implode;
use function preg_match;
use function preg_quote;
use function substr;
use const PREG_OFFSET_CAPTURE;
/**
* Converts positional (?) into named placeholders (:param<num>).
......
......@@ -9,7 +9,6 @@ use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Driver\Statement as DriverStatement;
use UnexpectedValueException;
use const OCI_DEFAULT;
use function addcslashes;
use function oci_commit;
use function oci_connect;
......@@ -20,6 +19,7 @@ use function oci_server_version;
use function preg_match;
use function sprintf;
use function str_replace;
use const OCI_DEFAULT;
/**
* OCI8 implementation of the Connection interface.
......@@ -84,17 +84,11 @@ final class OCI8Connection implements Connection, ServerInfoAwareConnection
return $matches[1];
}
/**
* {@inheritdoc}
*/
public function prepare(string $sql) : DriverStatement
{
return new OCI8Statement($this->dbh, $sql, $this->executionMode);
}
/**
* {@inheritdoc}
*/
public function query(string $sql) : ResultStatement
{
$stmt = $this->prepare($sql);
......@@ -103,17 +97,11 @@ final class OCI8Connection implements Connection, ServerInfoAwareConnection
return $stmt;
}
/**
* {@inheritdoc}
*/
public function quote(string $input) : string
{
return "'" . addcslashes(str_replace("'", "''", $input), "\000\n\r\\\032") . "'";
}
/**
* {@inheritdoc}
*/
public function exec(string $statement) : int
{
$stmt = $this->prepare($statement);
......@@ -122,9 +110,6 @@ final class OCI8Connection implements Connection, ServerInfoAwareConnection
return $stmt->rowCount();
}
/**
* {@inheritdoc}
*/
public function lastInsertId(?string $name = null) : string
{
if ($name === null) {
......@@ -142,17 +127,11 @@ final class OCI8Connection implements Connection, ServerInfoAwareConnection
return $result;
}
/**
* {@inheritdoc}
*/
public function beginTransaction() : void
{
$this->executionMode->disableAutoCommit();
}
/**
* {@inheritdoc}
*/
public function commit() : void
{
if (! oci_commit($this->dbh)) {
......@@ -162,9 +141,6 @@ final class OCI8Connection implements Connection, ServerInfoAwareConnection
$this->executionMode->enableAutoCommit();
}
/**
* {@inheritdoc}
*/
public function rollBack() : void
{
if (! oci_rollback($this->dbh)) {
......
......@@ -11,20 +11,6 @@ use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\ParameterType;
use InvalidArgumentException;
use IteratorAggregate;
use const OCI_ASSOC;
use const OCI_B_BIN;
use const OCI_B_BLOB;
use const OCI_BOTH;
use const OCI_COMMIT_ON_SUCCESS;
use const OCI_D_LOB;
use const OCI_FETCHSTATEMENT_BY_COLUMN;
use const OCI_FETCHSTATEMENT_BY_ROW;
use const OCI_NO_AUTO_COMMIT;
use const OCI_NUM;
use const OCI_RETURN_LOBS;
use const OCI_RETURN_NULLS;
use const OCI_TEMP_BLOB;
use const SQLT_CHR;
use function array_key_exists;
use function assert;
use function count;
......@@ -42,6 +28,20 @@ use function oci_num_fields;
use function oci_num_rows;
use function oci_parse;
use function sprintf;
use const OCI_ASSOC;
use const OCI_B_BIN;
use const OCI_B_BLOB;
use const OCI_BOTH;
use const OCI_COMMIT_ON_SUCCESS;
use const OCI_D_LOB;
use const OCI_FETCHSTATEMENT_BY_COLUMN;
use const OCI_FETCHSTATEMENT_BY_ROW;
use const OCI_NO_AUTO_COMMIT;
use const OCI_NUM;
use const OCI_RETURN_LOBS;
use const OCI_RETURN_NULLS;
use const OCI_TEMP_BLOB;
use const SQLT_CHR;
/**
* The OCI8 implementation of the Statement interface.
......@@ -161,18 +161,13 @@ final class OCI8Statement implements IteratorAggregate, Statement
switch ($type) {
case ParameterType::BINARY:
return OCI_B_BIN;
case ParameterType::LARGE_OBJECT:
return OCI_B_BLOB;
default:
return SQLT_CHR;
}
}
/**
* {@inheritdoc}
*/
public function closeCursor() : void
{
// not having the result means there's nothing to close
......@@ -185,9 +180,6 @@ final class OCI8Statement implements IteratorAggregate, Statement
$this->result = false;
}
/**
* {@inheritdoc}
*/
public function columnCount() : int
{
return oci_num_fields($this->_sth) ?: 0;
......@@ -349,9 +341,6 @@ final class OCI8Statement implements IteratorAggregate, Statement
return $row[$columnIndex];
}
/**
* {@inheritdoc}
*/
public function rowCount() : int
{
return oci_num_rows($this->_sth) ?: 0;
......
......@@ -32,9 +32,6 @@ class PDOConnection implements ServerInfoAwareConnection
}
}
/**
* {@inheritdoc}
*/
public function exec(string $statement) : int
{
try {
......@@ -44,17 +41,11 @@ class PDOConnection implements ServerInfoAwareConnection
}
}
/**
* {@inheritdoc}
*/
public function getServerVersion() : string
{
return $this->connection->getAttribute(PDO::ATTR_SERVER_VERSION);
}
/**
* {@inheritdoc}
*/
public function prepare(string $sql) : Statement
{
try {
......@@ -66,9 +57,6 @@ class PDOConnection implements ServerInfoAwareConnection
}
}
/**
* {@inheritdoc}
*/
public function query(string $sql) : ResultStatement
{
try {
......@@ -81,17 +69,11 @@ class PDOConnection implements ServerInfoAwareConnection
}
}
/**
* {@inheritdoc}
*/
public function quote(string $input) : string
{
return $this->connection->quote($input);
}
/**
* {@inheritdoc}
*/
public function lastInsertId(?string $name = null) : string
{
try {
......@@ -113,25 +95,16 @@ class PDOConnection implements ServerInfoAwareConnection
return new PDOStatement($stmt);
}
/**
* {@inheritDoc}
*/
public function beginTransaction() : void
{
$this->connection->beginTransaction();
}
/**
* {@inheritDoc}
*/
public function commit() : void
{
$this->connection->commit();
}
/**
* {@inheritDoc}
*/
public function rollBack() : void
{
$this->connection->rollBack();
......
......@@ -56,15 +56,19 @@ final class Driver extends AbstractMySQLDriver
if (isset($params['host']) && $params['host'] !== '') {
$dsn .= 'host=' . $params['host'] . ';';
}
if (isset($params['port'])) {
$dsn .= 'port=' . $params['port'] . ';';
}
if (isset($params['dbname'])) {
$dsn .= 'dbname=' . $params['dbname'] . ';';
}
if (isset($params['unix_socket'])) {
$dsn .= 'unix_socket=' . $params['unix_socket'] . ';';
}
if (isset($params['charset'])) {
$dsn .= 'charset=' . $params['charset'] . ';';
}
......
......@@ -14,9 +14,6 @@ use function substr;
*/
class Connection extends PDOConnection
{
/**
* {@inheritDoc}
*/
public function lastInsertId(?string $name = null) : string
{
if ($name === null) {
......@@ -29,9 +26,6 @@ class Connection extends PDOConnection
return $stmt->fetchColumn();
}
/**
* {@inheritDoc}
*/
public function quote(string $input) : string
{
$val = parent::quote($input);
......@@ -44,9 +38,6 @@ class Connection extends PDOConnection
return $val;
}
/**
* {@inheritDoc}
*/
protected function createStatement(\PDOStatement $stmt) : PDOStatement
{
return new Statement($stmt);
......
......@@ -96,17 +96,11 @@ class PDOStatement implements IteratorAggregate, Statement
}
}
/**
* {@inheritdoc}
*/
public function closeCursor() : void
{
$this->stmt->closeCursor();
}
/**
* {@inheritdoc}
*/
public function columnCount() : int
{
return $this->stmt->columnCount();
......@@ -124,9 +118,6 @@ class PDOStatement implements IteratorAggregate, Statement
}
}
/**
* {@inheritdoc}
*/
public function rowCount() : int
{
return $this->stmt->rowCount();
......
......@@ -81,9 +81,6 @@ final class SQLAnywhereConnection implements ServerInfoAwareConnection
$this->endTransaction();
}
/**
* {@inheritdoc}
*/
public function exec(string $statement) : int
{
if (sasql_real_query($this->connection, $statement) === false) {
......@@ -93,9 +90,6 @@ final class SQLAnywhereConnection implements ServerInfoAwareConnection
return sasql_affected_rows($this->connection);
}
/**
* {@inheritdoc}
*/
public function getServerVersion() : string
{
$version = $this->query("SELECT PROPERTY('ProductVersion')")->fetchColumn();
......@@ -105,9 +99,6 @@ final class SQLAnywhereConnection implements ServerInfoAwareConnection
return $version;
}
/**
* {@inheritdoc}
*/
public function lastInsertId(?string $name = null) : string
{
if ($name === null) {
......@@ -117,17 +108,11 @@ final class SQLAnywhereConnection implements ServerInfoAwareConnection
return $this->query('SELECT ' . $name . '.CURRVAL')->fetchColumn();
}
/**
* {@inheritdoc}
*/
public function prepare(string $sql) : DriverStatement
{
return new SQLAnywhereStatement($this->connection, $sql);
}
/**
* {@inheritdoc}
*/
public function query(string $sql) : ResultStatement
{
$stmt = $this->prepare($sql);
......@@ -136,9 +121,6 @@ final class SQLAnywhereConnection implements ServerInfoAwareConnection
return $stmt;
}
/**
* {@inheritdoc}
*/
public function quote(string $input) : string
{
return "'" . sasql_escape_string($this->connection, $input) . "'";
......
......@@ -14,7 +14,6 @@ use IteratorAggregate;
use ReflectionClass;
use ReflectionObject;
use stdClass;
use const SASQL_BOTH;
use function array_key_exists;
use function assert;
use function count;
......@@ -36,6 +35,7 @@ use function sasql_stmt_field_count;
use function sasql_stmt_reset;
use function sasql_stmt_result_metadata;
use function sprintf;
use const SASQL_BOTH;
/**
* SAP SQL Anywhere implementation of the Statement interface.
......@@ -132,17 +132,11 @@ final class SQLAnywhereStatement implements IteratorAggregate, Statement
$this->bindParam($param, $value, $type);
}
/**
* {@inheritdoc}
*/
public function closeCursor() : void
{
sasql_stmt_reset($this->stmt);
}
/**
* {@inheritdoc}
*/
public function columnCount() : int
{
return sasql_stmt_field_count($this->stmt);
......@@ -190,13 +184,10 @@ final class SQLAnywhereStatement implements IteratorAggregate, Statement
switch ($fetchMode) {
case FetchMode::COLUMN:
return $this->fetchColumn();
case FetchMode::ASSOCIATIVE:
return sasql_fetch_assoc($this->result);
case FetchMode::MIXED:
return sasql_fetch_array($this->result, SASQL_BOTH);
case FetchMode::CUSTOM_OBJECT:
$className = $this->defaultFetchClass;
$ctorArgs = $this->defaultFetchClassCtorArgs;
......@@ -213,13 +204,10 @@ final class SQLAnywhereStatement implements IteratorAggregate, Statement
}
return $result;
case FetchMode::NUMERIC:
return sasql_fetch_row($this->result);
case FetchMode::STANDARD_OBJECT:
return sasql_fetch_object($this->result);
default:
throw new SQLAnywhereException(sprintf('Fetch mode is not supported %d.', $fetchMode));
}
......@@ -237,12 +225,14 @@ final class SQLAnywhereStatement implements IteratorAggregate, Statement
while (($row = $this->fetch(...func_get_args())) !== false) {
$rows[] = $row;
}
break;
case FetchMode::COLUMN:
while (($row = $this->fetchColumn()) !== false) {
$rows[] = $row;
}
break;
default:
......@@ -280,9 +270,6 @@ final class SQLAnywhereStatement implements IteratorAggregate, Statement
return new StatementIterator($this);
}
/**
* {@inheritdoc}
*/
public function rowCount() : int
{
return sasql_stmt_affected_rows($this->stmt);
......
......@@ -49,9 +49,6 @@ final class SQLSrvConnection implements ServerInfoAwareConnection
$this->lastInsertId = new LastInsertId();
}
/**
* {@inheritdoc}
*/
public function getServerVersion() : string
{
$serverInfo = sqlsrv_server_info($this->conn);
......@@ -59,17 +56,11 @@ final class SQLSrvConnection implements ServerInfoAwareConnection
return $serverInfo['SQLServerVersion'];
}
/**
* {@inheritDoc}
*/
public function prepare(string $sql) : DriverStatement
{
return new SQLSrvStatement($this->conn, $sql, $this->lastInsertId);
}
/**
* {@inheritDoc}
*/
public function query(string $sql) : ResultStatement
{
$stmt = $this->prepare($sql);
......@@ -78,17 +69,11 @@ final class SQLSrvConnection implements ServerInfoAwareConnection
return $stmt;
}
/**
* {@inheritDoc}
*/
public function quote(string $input) : string
{
return "'" . str_replace("'", "''", $input) . "'";
}
/**
* {@inheritDoc}
*/
public function exec(string $statement) : int
{
$stmt = sqlsrv_query($this->conn, $statement);
......@@ -106,9 +91,6 @@ final class SQLSrvConnection implements ServerInfoAwareConnection
return $rowsAffected;
}
/**
* {@inheritDoc}
*/
public function lastInsertId(?string $name = null) : string
{
if ($name !== null) {
......@@ -121,9 +103,6 @@ final class SQLSrvConnection implements ServerInfoAwareConnection
return $stmt->fetchColumn();
}
/**
* {@inheritDoc}
*/
public function beginTransaction() : void
{
if (! sqlsrv_begin_transaction($this->conn)) {
......@@ -131,9 +110,6 @@ final class SQLSrvConnection implements ServerInfoAwareConnection
}
}
/**
* {@inheritDoc}
*/
public function commit() : void
{
if (! sqlsrv_commit($this->conn)) {
......@@ -141,9 +117,6 @@ final class SQLSrvConnection implements ServerInfoAwareConnection
}
}
/**
* {@inheritDoc}
*/
public function rollBack() : void
{
if (! sqlsrv_rollback($this->conn)) {
......
......@@ -5,9 +5,9 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\SQLSrv;
use Doctrine\DBAL\Driver\AbstractDriverException;
use const SQLSRV_ERR_ERRORS;
use function rtrim;
use function sqlsrv_errors;
use const SQLSRV_ERR_ERRORS;
class SQLSrvException extends AbstractDriverException
{
......
......@@ -10,11 +10,6 @@ use Doctrine\DBAL\Exception\InvalidColumnIndex;
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\ParameterType;
use IteratorAggregate;
use const SQLSRV_ENC_BINARY;
use const SQLSRV_FETCH_ASSOC;
use const SQLSRV_FETCH_BOTH;
use const SQLSRV_FETCH_NUMERIC;
use const SQLSRV_PARAM_IN;
use function array_key_exists;
use function assert;
use function count;
......@@ -33,6 +28,11 @@ use function sqlsrv_prepare;
use function sqlsrv_rows_affected;
use function SQLSRV_SQLTYPE_VARBINARY;
use function stripos;
use const SQLSRV_ENC_BINARY;
use const SQLSRV_FETCH_ASSOC;
use const SQLSRV_FETCH_BOTH;
use const SQLSRV_FETCH_NUMERIC;
use const SQLSRV_PARAM_IN;
/**
* SQL Server Statement.
......@@ -166,9 +166,6 @@ final class SQLSrvStatement implements IteratorAggregate, Statement
$this->stmt = null;
}
/**
* {@inheritdoc}
*/
public function closeCursor() : void
{
// not having the result means there's nothing to close
......@@ -186,9 +183,6 @@ final class SQLSrvStatement implements IteratorAggregate, Statement
$this->result = false;
}
/**
* {@inheritdoc}
*/
public function columnCount() : int
{
if ($this->stmt === null) {
......@@ -306,12 +300,14 @@ final class SQLSrvStatement implements IteratorAggregate, Statement
while (($row = $this->fetch($fetchMode, ...$args)) !== false) {
$rows[] = $row;
}
break;
case FetchMode::COLUMN:
while (($row = $this->fetchColumn()) !== false) {
$rows[] = $row;
}
break;
default:
......@@ -341,9 +337,6 @@ final class SQLSrvStatement implements IteratorAggregate, Statement
return $row[$columnIndex];
}
/**
* {@inheritdoc}
*/
public function rowCount() : int
{
if ($this->stmt === null) {
......
......@@ -145,6 +145,7 @@ final class DriverManager
if (! $config) {
$config = new Configuration();
}
if (! $eventManager) {
$eventManager = new EventManager();
}
......@@ -263,12 +264,15 @@ final class DriverManager
if (isset($url['host'])) {
$params['host'] = $url['host'];
}
if (isset($url['port'])) {
$params['port'] = $url['port'];
}
if (isset($url['user'])) {
$params['user'] = $url['user'];
}
if (isset($url['pass'])) {
$params['password'] = $url['pass'];
}
......
......@@ -7,11 +7,11 @@ namespace Doctrine\DBAL\Event\Listeners;
use Doctrine\Common\EventSubscriber;
use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Events;
use const CASE_UPPER;
use function array_change_key_case;
use function array_merge;
use function count;
use function implode;
use const CASE_UPPER;
/**
* Should be used when Oracle Server default environment does not match the Doctrine requirements.
......@@ -57,6 +57,7 @@ class OracleSessionInit implements EventSubscriber
$vars[] = $option . " = '" . $value . "'";
}
}
$sql = 'ALTER SESSION SET ' . implode(' ', $vars);
$args->getConnection()->executeUpdate($sql);
}
......
......@@ -22,9 +22,6 @@ class DriverException extends DBALException implements DriverExceptionInterface
parent::__construct($message, $driverException->getCode(), $driverException);
}
/**
* {@inheritDoc}
*/
public function getSQLState() : ?string
{
$previous = $this->getPrevious();
......
......@@ -10,9 +10,9 @@ use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\LockMode;
use Throwable;
use const CASE_LOWER;
use function array_change_key_case;
use function sprintf;
use const CASE_LOWER;
/**
* Table ID Generator for those poor languages that are missing sequences.
......@@ -71,6 +71,7 @@ class TableGenerator
if ($params['driver'] === 'pdo_sqlite') {
throw new DBALException('Cannot use TableGenerator with SQLite.');
}
$this->conn = DriverManager::getConnection($params, $conn->getConfiguration(), $conn->getEventManager());
$this->generatorTableName = $generatorTableName;
}
......@@ -134,6 +135,7 @@ class TableGenerator
$this->conn->commit();
} catch (Throwable $e) {
$this->conn->rollBack();
throw new DBALException(sprintf('Error occurred while generating ID with TableGenerator, aborted generation with error: %s', $e->getMessage()), 0, $e);
}
......
......@@ -22,9 +22,6 @@ final class TableGeneratorSchemaVisitor implements Visitor
$this->generatorTableName = $generatorTableName;
}
/**
* {@inheritdoc}
*/
public function acceptSchema(Schema $schema) : void
{
$table = $schema->createTable($this->generatorTableName);
......@@ -34,37 +31,22 @@ final class TableGeneratorSchemaVisitor implements Visitor
$table->addColumn('sequence_increment_by', 'integer', ['default' => 1]);
}
/**
* {@inheritdoc}
*/
public function acceptTable(Table $table) : void
{
}
/**
* {@inheritdoc}
*/
public function acceptColumn(Table $table, Column $column) : void
{
}
/**
* {@inheritdoc}
*/
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) : void
{
}
/**
* {@inheritdoc}
*/
public function acceptIndex(Table $table, Index $index) : void
{
}
/**
* {@inheritdoc}
*/
public function acceptSequence(Sequence $sequence) : void
{
}
......
......@@ -44,9 +44,6 @@ final class DebugStack implements SQLLogger
$this->queries[++$this->currentQuery] = ['sql' => $sql, 'params' => $params, 'types' => $types, 'executionMS' => 0];
}
/**
* {@inheritdoc}
*/
public function stopQuery() : void
{
if (! $this->enabled) {
......
......@@ -4,8 +4,8 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Logging;
use const PHP_EOL;
use function var_dump;
use const PHP_EOL;
/**
* A SQL logger that logs to the standard output using echo/var_dump.
......@@ -30,9 +30,6 @@ final class EchoSQLLogger implements SQLLogger
var_dump($types);
}
/**
* {@inheritdoc}
*/
public function stopQuery() : void
{
}
......
......@@ -30,9 +30,6 @@ final class LoggerChain implements SQLLogger
}
}
/**
* {@inheritdoc}
*/
public function stopQuery() : void
{
foreach ($this->loggers as $logger) {
......
......@@ -18,9 +18,6 @@ final class NullLogger implements SQLLogger
{
}
/**
* {@inheritdoc}
*/
public function stopQuery() : void
{
}
......
......@@ -1300,7 +1300,7 @@ abstract class AbstractPlatform
if (($createFlags & self::CREATE_INDEXES) > 0) {
foreach ($table->getIndexes() as $index) {
/** @var $index Index */
assert($index instanceof Index);
if (! $index->isPrimary()) {
$options['indexes'][$index->getQuotedName($this)] = $index;
......@@ -1366,6 +1366,7 @@ abstract class AbstractPlatform
if ($table->hasOption('comment')) {
$sql[] = $this->getCommentOnTableSQL($tableName, $table->getOption('comment'));
}
foreach ($table->getColumns() as $column) {
$comment = $this->getColumnComment($column);
......@@ -1452,6 +1453,7 @@ abstract class AbstractPlatform
if (! empty($check)) {
$query .= ', ' . $check;
}
$query .= ')';
$sql = [$query];
......@@ -1524,6 +1526,7 @@ abstract class AbstractPlatform
$referencesClause = ' REFERENCES ' . $constraint->getQuotedForeignTableName($this) .
' (' . implode(', ', $constraint->getQuotedForeignColumns($this)) . ')';
}
$query .= ' ' . $columnList . $referencesClause;
return $query;
......@@ -1541,6 +1544,7 @@ abstract class AbstractPlatform
if ($table instanceof Table) {
$table = $table->getQuotedName($this);
}
$name = $index->getQuotedName($this);
$columns = $index->getColumns();
......@@ -1786,6 +1790,7 @@ abstract class AbstractPlatform
foreach ($diff->removedForeignKeys as $foreignKey) {
$sql[] = $this->getDropForeignKeySQL($foreignKey, $tableName);
}
foreach ($diff->changedForeignKeys as $foreignKey) {
$sql[] = $this->getDropForeignKeySQL($foreignKey, $tableName);
}
......@@ -1794,6 +1799,7 @@ abstract class AbstractPlatform
foreach ($diff->removedIndexes as $index) {
$sql[] = $this->getDropIndexSQL($index, $tableName);
}
foreach ($diff->changedIndexes as $index) {
$sql[] = $this->getDropIndexSQL($index, $tableName);
}
......@@ -2215,6 +2221,7 @@ abstract class AbstractPlatform
if ($this->supportsForeignKeyOnUpdate() && $foreignKey->hasOption('onUpdate')) {
$query .= ' ON UPDATE ' . $this->getForeignKeyReferentialActionSQL($foreignKey->getOption('onUpdate'));
}
if ($foreignKey->hasOption('onDelete')) {
$query .= ' ON DELETE ' . $this->getForeignKeyReferentialActionSQL($foreignKey->getOption('onDelete'));
}
......@@ -2256,14 +2263,17 @@ abstract class AbstractPlatform
if ($foreignKey->getName() !== '') {
$sql .= 'CONSTRAINT ' . $foreignKey->getQuotedName($this) . ' ';
}
$sql .= 'FOREIGN KEY (';
if (count($foreignKey->getLocalColumns()) === 0) {
throw new InvalidArgumentException('Incomplete definition. "local" required.');
}
if (count($foreignKey->getForeignColumns()) === 0) {
throw new InvalidArgumentException('Incomplete definition. "foreign" required.');
}
if (strlen($foreignKey->getForeignTableName()) === 0) {
throw new InvalidArgumentException('Incomplete definition. "foreignTable" required.');
}
......
......@@ -31,9 +31,6 @@ class DB2Platform extends AbstractPlatform
return 'BLOB(1M)';
}
/**
* {@inheritDoc}
*/
public function initializeDoctrineTypeMappings() : void
{
$this->doctrineTypeMapping = [
......@@ -55,9 +52,6 @@ class DB2Platform extends AbstractPlatform
];
}
/**
* {@inheritdoc}
*/
public function isCommentedDoctrineType(Type $doctrineType) : bool
{
if ($doctrineType->getName() === Types::BOOLEAN) {
......@@ -69,17 +63,11 @@ class DB2Platform extends AbstractPlatform
return parent::isCommentedDoctrineType($doctrineType);
}
/**
* {@inheritDoc}
*/
protected function getBinaryTypeDeclarationSQLSnippet(?int $length) : string
{
return $this->getCharTypeDeclarationSQLSnippet($length) . ' FOR BIT DATA';
}
/**
* {@inheritDoc}
*/
protected function getVarbinaryTypeDeclarationSQLSnippet(?int $length) : string
{
return $this->getVarcharTypeDeclarationSQLSnippet($length) . ' FOR BIT DATA';
......@@ -94,9 +82,6 @@ class DB2Platform extends AbstractPlatform
return 'CLOB(1M)';
}
/**
* {@inheritDoc}
*/
public function getName() : string
{
return 'db2';
......@@ -147,25 +132,16 @@ class DB2Platform extends AbstractPlatform
return $autoinc;
}
/**
* {@inheritdoc}
*/
public function getBitAndComparisonExpression(string $value1, string $value2) : string
{
return 'BITAND(' . $value1 . ', ' . $value2 . ')';
}
/**
* {@inheritdoc}
*/
public function getBitOrComparisonExpression(string $value1, string $value2) : string
{
return 'BITOR(' . $value1 . ', ' . $value2 . ')';
}
/**
* {@inheritdoc}
*/
protected function getDateArithmeticIntervalExpression(string $date, string $operator, string $interval, string $unit) : string
{
switch ($unit) {
......@@ -183,9 +159,6 @@ class DB2Platform extends AbstractPlatform
return $date . ' ' . $operator . ' ' . $interval . ' ' . $unit;
}
/**
* {@inheritdoc}
*/
public function getDateDiffExpression(string $date1, string $date2) : string
{
return 'DAYS(' . $date1 . ') - DAYS(' . $date2 . ')';
......@@ -219,9 +192,6 @@ class DB2Platform extends AbstractPlatform
return 'TIME';
}
/**
* {@inheritdoc}
*/
public function getTruncateTableSQL(string $tableName, bool $cascade = false) : string
{
$tableIdentifier = new Identifier($tableName);
......@@ -280,25 +250,16 @@ class DB2Platform extends AbstractPlatform
';
}
/**
* {@inheritDoc}
*/
public function getListTablesSQL() : string
{
return "SELECT NAME FROM SYSIBM.SYSTABLES WHERE TYPE = 'T'";
}
/**
* {@inheritDoc}
*/
public function getListViewsSQL(string $database) : string
{
return 'SELECT NAME, TEXT FROM SYSIBM.SYSVIEWS';
}
/**
* {@inheritDoc}
*/
public function getListTableIndexesSQL(string $table, ?string $currentDatabase = null) : string
{
$table = $this->quoteStringLiteral($table);
......@@ -320,9 +281,6 @@ class DB2Platform extends AbstractPlatform
ORDER BY idxcol.COLSEQ ASC';
}
/**
* {@inheritDoc}
*/
public function getListTableForeignKeysSQL(string $table, ?string $database = null) : string
{
$table = $this->quoteStringLiteral($table);
......@@ -354,89 +312,56 @@ class DB2Platform extends AbstractPlatform
ORDER BY fkcol.COLSEQ ASC';
}
/**
* {@inheritDoc}
*/
public function getCreateViewSQL(string $name, string $sql) : string
{
return 'CREATE VIEW ' . $name . ' AS ' . $sql;
}
/**
* {@inheritDoc}
*/
public function getDropViewSQL(string $name) : string
{
return 'DROP VIEW ' . $name;
}
/**
* {@inheritDoc}
*/
public function getCreateDatabaseSQL(string $database) : string
{
return 'CREATE DATABASE ' . $database;
}
/**
* {@inheritDoc}
*/
public function getDropDatabaseSQL(string $database) : string
{
return 'DROP DATABASE ' . $database;
}
/**
* {@inheritDoc}
*/
public function supportsCreateDropDatabase() : bool
{
return false;
}
/**
* {@inheritDoc}
*/
public function supportsReleaseSavepoints() : bool
{
return false;
}
/**
* {@inheritdoc}
*/
public function supportsCommentOnStatement() : bool
{
return true;
}
/**
* {@inheritDoc}
*/
public function getCurrentDateSQL() : string
{
return 'CURRENT DATE';
}
/**
* {@inheritDoc}
*/
public function getCurrentTimeSQL() : string
{
return 'CURRENT TIME';
}
/**
* {@inheritDoc}
*/
public function getCurrentTimestampSQL() : string
{
return 'CURRENT TIMESTAMP';
}
/**
* {@inheritDoc}
*/
public function getIndexDeclarationSQL(string $name, Index $index) : string
{
// Index declaration in statements like CREATE TABLE is not supported.
......@@ -452,6 +377,7 @@ class DB2Platform extends AbstractPlatform
if (isset($options['indexes'])) {
$indexes = $options['indexes'];
}
$options['indexes'] = [];
$sqls = parent::_getCreateTableSQL($tableName, $columns, $options);
......@@ -719,33 +645,21 @@ class DB2Platform extends AbstractPlatform
return parent::getDefaultValueDeclarationSQL($field);
}
/**
* {@inheritDoc}
*/
public function getEmptyIdentityInsertSQL(string $tableName, string $identifierColumnName) : string
{
return 'INSERT INTO ' . $tableName . ' (' . $identifierColumnName . ') VALUES (DEFAULT)';
}
/**
* {@inheritDoc}
*/
public function getCreateTemporaryTableSnippetSQL() : string
{
return 'DECLARE GLOBAL TEMPORARY TABLE';
}
/**
* {@inheritDoc}
*/
public function getTemporaryTableName(string $tableName) : string
{
return 'SESSION.' . $tableName;
}
/**
* {@inheritDoc}
*/
protected function doModifyLimitQuery(string $query, ?int $limit, int $offset) : string
{
$where = [];
......@@ -770,9 +684,6 @@ class DB2Platform extends AbstractPlatform
);
}
/**
* {@inheritDoc}
*/
public function getLocateExpression(string $string, string $substring, ?string $start = null) : string
{
if ($start === null) {
......@@ -782,9 +693,6 @@ class DB2Platform extends AbstractPlatform
return sprintf('LOCATE(%s, %s, %s)', $substring, $string, $start);
}
/**
* {@inheritDoc}
*/
public function getSubstringExpression(string $string, string $start, ?string $length = null) : string
{
if ($length === null) {
......@@ -794,25 +702,16 @@ class DB2Platform extends AbstractPlatform
return sprintf('SUBSTR(%s, %s, %s)', $string, $start, $length);
}
/**
* {@inheritDoc}
*/
public function getCurrentDatabaseExpression() : string
{
return 'CURRENT_USER';
}
/**
* {@inheritDoc}
*/
public function supportsIdentityColumns() : bool
{
return true;
}
/**
* {@inheritDoc}
*/
public function prefersIdentityColumns() : bool
{
return true;
......@@ -828,17 +727,11 @@ class DB2Platform extends AbstractPlatform
return strtoupper($column);
}
/**
* {@inheritDoc}
*/
public function getForUpdateSQL() : string
{
return ' WITH RR USE AND KEEP UPDATE LOCKS';
}
/**
* {@inheritDoc}
*/
public function getDummySelectSQL(string $expression = '1') : string
{
return sprintf('SELECT %s FROM sysibm.sysdummy1', $expression);
......@@ -856,9 +749,6 @@ class DB2Platform extends AbstractPlatform
return false;
}
/**
* {@inheritDoc}
*/
protected function getReservedKeywordsClass() : string
{
return Keywords\DB2Keywords::class;
......
......@@ -9,9 +9,6 @@ namespace Doctrine\DBAL\Platforms\Keywords;
*/
class DB2Keywords extends KeywordList
{
/**
* {@inheritdoc}
*/
public function getName() : string
{
return 'DB2';
......
......@@ -11,9 +11,6 @@ namespace Doctrine\DBAL\Platforms\Keywords;
*/
final class MariaDb102Keywords extends MySQLKeywords
{
/**
* {@inheritdoc}
*/
public function getName() : string
{
return 'MariaDb102';
......
......@@ -9,9 +9,6 @@ namespace Doctrine\DBAL\Platforms\Keywords;
*/
class MySQL57Keywords extends MySQLKeywords
{
/**
* {@inheritdoc}
*/
public function getName() : string
{
return 'MySQL57';
......
......@@ -11,9 +11,6 @@ use function array_merge;
*/
class MySQL80Keywords extends MySQL57Keywords
{
/**
* {@inheritdoc}
*/
public function getName() : string
{
return 'MySQL80';
......
......@@ -9,9 +9,6 @@ namespace Doctrine\DBAL\Platforms\Keywords;
*/
class MySQLKeywords extends KeywordList
{
/**
* {@inheritdoc}
*/
public function getName() : string
{
return 'MySQL';
......
......@@ -9,9 +9,6 @@ namespace Doctrine\DBAL\Platforms\Keywords;
*/
class OracleKeywords extends KeywordList
{
/**
* {@inheritdoc}
*/
public function getName() : string
{
return 'Oracle';
......
......@@ -9,9 +9,6 @@ namespace Doctrine\DBAL\Platforms\Keywords;
*/
class PostgreSQL100Keywords extends PostgreSQLKeywords
{
/**
* {@inheritdoc}
*/
public function getName() : string
{
return 'PostgreSQL100';
......
......@@ -9,9 +9,6 @@ namespace Doctrine\DBAL\Platforms\Keywords;
*/
class PostgreSQLKeywords extends KeywordList
{
/**
* {@inheritdoc}
*/
public function getName() : string
{
return 'PostgreSQL';
......
......@@ -71,9 +71,6 @@ class ReservedKeywordsValidator implements Visitor
$this->violations[] = $asset . ' keyword violations: ' . implode(', ', $violatedPlatforms);
}
/**
* {@inheritdoc}
*/
public function acceptColumn(Table $table, Column $column) : void
{
$this->addViolation(
......@@ -82,37 +79,22 @@ class ReservedKeywordsValidator implements Visitor
);
}
/**
* {@inheritdoc}
*/
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) : void
{
}
/**
* {@inheritdoc}
*/
public function acceptIndex(Table $table, Index $index) : void
{
}
/**
* {@inheritdoc}
*/
public function acceptSchema(Schema $schema) : void
{
}
/**
* {@inheritdoc}
*/
public function acceptSequence(Sequence $sequence) : void
{
}
/**
* {@inheritdoc}
*/
public function acceptTable(Table $table) : void
{
$this->addViolation(
......
......@@ -9,9 +9,6 @@ namespace Doctrine\DBAL\Platforms\Keywords;
*/
class SQLAnywhereKeywords extends KeywordList
{
/**
* {@inheritdoc}
*/
public function getName() : string
{
return 'SQLAnywhere';
......
......@@ -11,9 +11,6 @@ namespace Doctrine\DBAL\Platforms\Keywords;
*/
class SQLServerKeywords extends KeywordList
{
/**
* {@inheritdoc}
*/
public function getName() : string
{
return 'SQLServer';
......
......@@ -9,9 +9,6 @@ namespace Doctrine\DBAL\Platforms\Keywords;
*/
class SQLiteKeywords extends KeywordList
{
/**
* {@inheritdoc}
*/
public function getName() : string
{
return 'SQLite';
......
......@@ -23,17 +23,11 @@ final class MariaDb1027Platform extends MySqlPlatform
return 'LONGTEXT';
}
/**
* {@inheritdoc}
*/
protected function getReservedKeywordsClass() : string
{
return Keywords\MariaDb102Keywords::class;
}
/**
* {@inheritdoc}
*/
protected function initializeDoctrineTypeMappings() : void
{
parent::initializeDoctrineTypeMappings();
......
......@@ -13,9 +13,6 @@ use Doctrine\DBAL\Types\Types;
*/
class MySQL57Platform extends MySqlPlatform
{
/**
* {@inheritdoc}
*/
public function hasNativeJsonType() : bool
{
return true;
......@@ -53,17 +50,11 @@ class MySQL57Platform extends MySqlPlatform
return ['ALTER TABLE ' . $tableName . ' RENAME INDEX ' . $oldIndexName . ' TO ' . $index->getQuotedName($this)];
}
/**
* {@inheritdoc}
*/
protected function getReservedKeywordsClass() : string
{
return Keywords\MySQL57Keywords::class;
}
/**
* {@inheritdoc}
*/
protected function initializeDoctrineTypeMappings() : void
{
parent::initializeDoctrineTypeMappings();
......
......@@ -9,9 +9,6 @@ namespace Doctrine\DBAL\Platforms;
*/
class MySQL80Platform extends MySQL57Platform
{
/**
* {@inheritdoc}
*/
protected function getReservedKeywordsClass() : string
{
return Keywords\MySQL80Keywords::class;
......
......@@ -44,9 +44,6 @@ class MySqlPlatform extends AbstractPlatform
public const LENGTH_LIMIT_BLOB = 65535;
public const LENGTH_LIMIT_MEDIUMBLOB = 16777215;
/**
* {@inheritDoc}
*/
protected function doModifyLimitQuery(string $query, ?int $limit, int $offset) : string
{
if ($limit !== null) {
......@@ -63,25 +60,16 @@ class MySqlPlatform extends AbstractPlatform
return $query;
}
/**
* {@inheritDoc}
*/
public function getIdentifierQuoteCharacter() : string
{
return '`';
}
/**
* {@inheritDoc}
*/
public function getRegexpExpression() : string
{
return 'RLIKE';
}
/**
* {@inheritDoc}
*/
public function getLocateExpression(string $string, string $substring, ?string $start = null) : string
{
if ($start === null) {
......@@ -91,17 +79,11 @@ class MySqlPlatform extends AbstractPlatform
return sprintf('LOCATE(%s, %s, %s)', $substring, $string, $start);
}
/**
* {@inheritDoc}
*/
public function getConcatExpression(string ...$string) : string
{
return sprintf('CONCAT(%s)', implode(', ', $string));
}
/**
* {@inheritdoc}
*/
protected function getDateArithmeticIntervalExpression(string $date, string $operator, string $interval, string $unit) : string
{
$function = $operator === '+' ? 'DATE_ADD' : 'DATE_SUB';
......@@ -109,33 +91,21 @@ class MySqlPlatform extends AbstractPlatform
return $function . '(' . $date . ', INTERVAL ' . $interval . ' ' . $unit . ')';
}
/**
* {@inheritDoc}
*/
public function getDateDiffExpression(string $date1, string $date2) : string
{
return 'DATEDIFF(' . $date1 . ', ' . $date2 . ')';
}
/**
* {@inheritDoc}
*/
public function getCurrentDatabaseExpression() : string
{
return 'DATABASE()';
}
/**
* {@inheritDoc}
*/
public function getListDatabasesSQL() : string
{
return 'SHOW DATABASES';
}
/**
* {@inheritDoc}
*/
public function getListTableConstraintsSQL(string $table) : string
{
return 'SHOW INDEX FROM ' . $table;
......@@ -163,17 +133,11 @@ class MySqlPlatform extends AbstractPlatform
return 'SHOW INDEX FROM ' . $table;
}
/**
* {@inheritDoc}
*/
public function getListViewsSQL(string $database) : string
{
return 'SELECT * FROM information_schema.VIEWS WHERE TABLE_SCHEMA = ' . $this->quoteStringLiteral($database);
}
/**
* {@inheritDoc}
*/
public function getListTableForeignKeysSQL(string $table, ?string $database = null) : string
{
$table = $this->quoteStringLiteral($table);
......@@ -193,17 +157,11 @@ class MySqlPlatform extends AbstractPlatform
return $sql;
}
/**
* {@inheritDoc}
*/
public function getCreateViewSQL(string $name, string $sql) : string
{
return 'CREATE VIEW ' . $name . ' AS ' . $sql;
}
/**
* {@inheritDoc}
*/
public function getDropViewSQL(string $name) : string
{
return 'DROP VIEW ' . $name;
......@@ -296,33 +254,21 @@ class MySqlPlatform extends AbstractPlatform
return true;
}
/**
* {@inheritDoc}
*/
public function supportsInlineColumnComments() : bool
{
return true;
}
/**
* {@inheritDoc}
*/
public function supportsColumnCollation() : bool
{
return true;
}
/**
* {@inheritDoc}
*/
public function getListTablesSQL() : string
{
return "SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'";
}
/**
* {@inheritDoc}
*/
public function getListTableColumnsSQL(string $table, ?string $database = null) : string
{
return 'SELECT COLUMN_NAME AS Field, COLUMN_TYPE AS Type, IS_NULLABLE AS `Null`, ' .
......@@ -346,17 +292,11 @@ SQL
);
}
/**
* {@inheritDoc}
*/
public function getCreateDatabaseSQL(string $database) : string
{
return 'CREATE DATABASE ' . $database;
}
/**
* {@inheritDoc}
*/
public function getDropDatabaseSQL(string $database) : string
{
return 'DROP DATABASE ' . $database;
......@@ -580,6 +520,7 @@ SQL
if (count($queryParts) > 0) {
$sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' ' . implode(', ', $queryParts);
}
$sql = array_merge(
$this->getPreAlterTableIndexForeignKeySQL($diff),
$sql,
......@@ -823,9 +764,6 @@ SQL
return $sql;
}
/**
* {@inheritDoc}
*/
protected function getCreateIndexSQLFlags(Index $index) : string
{
$type = '';
......@@ -903,31 +841,23 @@ SQL
return $this->getUnsignedDeclaration($columnDef) . $autoinc;
}
/**
* {@inheritDoc}
*/
public function getColumnCharsetDeclarationSQL(string $charset) : string
{
return 'CHARACTER SET ' . $charset;
}
/**
* {@inheritDoc}
*/
public function getColumnCollationDeclarationSQL(string $collation) : string
{
return 'COLLATE ' . $this->quoteSingleIdentifier($collation);
}
/**
* {@inheritDoc}
*/
public function getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreignKey) : string
{
$query = '';
if ($foreignKey->hasOption('match')) {
$query .= ' MATCH ' . $foreignKey->getOption('match');
}
$query .= parent::getAdvancedForeignKeyOptionsSQL($foreignKey);
return $query;
......@@ -966,33 +896,21 @@ SQL
return 'ALTER TABLE ' . $table . ' DROP PRIMARY KEY';
}
/**
* {@inheritDoc}
*/
public function getSetTransactionIsolationSQL(int $level) : string
{
return 'SET SESSION TRANSACTION ISOLATION LEVEL ' . $this->_getTransactionIsolationLevelSQL($level);
}
/**
* {@inheritDoc}
*/
public function getName() : string
{
return 'mysql';
}
/**
* {@inheritDoc}
*/
public function getReadLockSQL() : string
{
return 'LOCK IN SHARE MODE';
}
/**
* {@inheritDoc}
*/
protected function initializeDoctrineTypeMappings() : void
{
$this->doctrineTypeMapping = [
......@@ -1029,9 +947,6 @@ SQL
];
}
/**
* {@inheritDoc}
*/
protected function getReservedKeywordsClass() : string
{
return Keywords\MySQLKeywords::class;
......@@ -1084,9 +999,6 @@ SQL
return 'LONGBLOB';
}
/**
* {@inheritdoc}
*/
public function quoteStringLiteral(string $str) : string
{
$str = str_replace('\\', '\\\\', $str); // MySQL requires backslashes to be escaped aswell.
......@@ -1094,17 +1006,11 @@ SQL
return parent::quoteStringLiteral($str);
}
/**
* {@inheritdoc}
*/
public function getDefaultTransactionIsolationLevel() : int
{
return TransactionIsolationLevel::REPEATABLE_READ;
}
/**
* {@inheritdoc}
*/
public function supportsColumnLengthIndexes() : bool
{
return true;
......
......@@ -11,9 +11,6 @@ use Doctrine\DBAL\Platforms\Keywords\PostgreSQL100Keywords;
*/
class PostgreSQL100Platform extends PostgreSqlPlatform
{
/**
* {@inheritdoc}
*/
protected function getReservedKeywordsClass() : string
{
return PostgreSQL100Keywords::class;
......
......@@ -34,17 +34,11 @@ use function trim;
*/
class SqlitePlatform extends AbstractPlatform
{
/**
* {@inheritDoc}
*/
public function getRegexpExpression() : string
{
return 'REGEXP';
}
/**
* {@inheritDoc}
*/
public function getNowExpression(string $type = 'timestamp') : string
{
switch ($type) {
......@@ -58,9 +52,6 @@ class SqlitePlatform extends AbstractPlatform
}
}
/**
* {@inheritDoc}
*/
public function getTrimExpression(string $str, int $mode = TrimMode::UNSPECIFIED, ?string $char = null) : string
{
switch ($mode) {
......@@ -95,9 +86,6 @@ class SqlitePlatform extends AbstractPlatform
return sprintf('%s(%s)', $trimFn, implode(', ', $arguments));
}
/**
* {@inheritDoc}
*/
public function getSubstringExpression(string $string, string $start, ?string $length = null) : string
{
if ($length === null) {
......@@ -107,9 +95,6 @@ class SqlitePlatform extends AbstractPlatform
return sprintf('SUBSTR(%s, %s, %s)', $string, $start, $length);
}
/**
* {@inheritDoc}
*/
public function getLocateExpression(string $string, string $substring, ?string $start = null) : string
{
if ($start === null) {
......@@ -119,9 +104,6 @@ class SqlitePlatform extends AbstractPlatform
return sprintf('LOCATE(%s, %s, %s)', $string, $substring, $start);
}
/**
* {@inheritdoc}
*/
protected function getDateArithmeticIntervalExpression(string $date, string $operator, string $interval, string $unit) : string
{
switch ($unit) {
......@@ -143,9 +125,6 @@ class SqlitePlatform extends AbstractPlatform
) . ')';
}
/**
* {@inheritDoc}
*/
public function getDateDiffExpression(string $date1, string $date2) : string
{
return sprintf("JULIANDAY(%s, 'start of day') - JULIANDAY(%s, 'start of day')", $date1, $date2);
......@@ -164,9 +143,6 @@ class SqlitePlatform extends AbstractPlatform
return "''";
}
/**
* {@inheritDoc}
*/
protected function _getTransactionIsolationLevelSQL(int $level) : string
{
switch ($level) {
......@@ -181,17 +157,11 @@ class SqlitePlatform extends AbstractPlatform
}
}
/**
* {@inheritDoc}
*/
public function getSetTransactionIsolationSQL(int $level) : string
{
return 'PRAGMA read_uncommitted = ' . $this->_getTransactionIsolationLevelSQL($level);
}
/**
* {@inheritDoc}
*/
public function prefersIdentityColumns() : bool
{
return true;
......@@ -302,9 +272,6 @@ class SqlitePlatform extends AbstractPlatform
return ! empty($columnDef['unsigned']) ? ' UNSIGNED' : '';
}
/**
* {@inheritDoc}
*/
public function getForeignKeyDeclarationSQL(ForeignKeyConstraint $foreignKey) : string
{
return parent::getForeignKeyDeclarationSQL(new ForeignKeyConstraint(
......@@ -391,17 +358,11 @@ class SqlitePlatform extends AbstractPlatform
return ', PRIMARY KEY(' . implode(', ', $keyColumns) . ')';
}
/**
* {@inheritdoc}
*/
protected function getBinaryTypeDeclarationSQLSnippet(?int $length) : string
{
return 'BLOB';
}
/**
* {@inheritdoc}
*/
protected function getVarcharTypeDeclarationSQLSnippet(?int $length) : string
{
$sql = 'VARCHAR';
......@@ -413,9 +374,6 @@ class SqlitePlatform extends AbstractPlatform
return $sql;
}
/**
* {@inheritDoc}
*/
protected function getVarbinaryTypeDeclarationSQLSnippet(?int $length) : string
{
return 'BLOB';
......@@ -429,9 +387,6 @@ class SqlitePlatform extends AbstractPlatform
return 'CLOB';
}
/**
* {@inheritDoc}
*/
public function getListTableConstraintsSQL(string $table) : string
{
$table = str_replace('.', '__', $table);
......@@ -442,9 +397,6 @@ class SqlitePlatform extends AbstractPlatform
);
}
/**
* {@inheritDoc}
*/
public function getListTableColumnsSQL(string $table, ?string $database = null) : string
{
$table = str_replace('.', '__', $table);
......@@ -452,9 +404,6 @@ class SqlitePlatform extends AbstractPlatform
return sprintf('PRAGMA table_info(%s)', $this->quoteStringLiteral($table));
}
/**
* {@inheritDoc}
*/
public function getListTableIndexesSQL(string $table, ?string $currentDatabase = null) : string
{
$table = str_replace('.', '__', $table);
......@@ -462,9 +411,6 @@ class SqlitePlatform extends AbstractPlatform
return sprintf('PRAGMA index_list(%s)', $this->quoteStringLiteral($table));
}
/**
* {@inheritDoc}
*/
public function getListTablesSQL() : string
{
return "SELECT name FROM sqlite_master WHERE type = 'table' AND name != 'sqlite_sequence' AND name != 'geometry_columns' AND name != 'spatial_ref_sys' "
......@@ -472,33 +418,21 @@ class SqlitePlatform extends AbstractPlatform
. "WHERE type = 'table' ORDER BY name";
}
/**
* {@inheritDoc}
*/
public function getListViewsSQL(string $database) : string
{
return "SELECT name, sql FROM sqlite_master WHERE type='view' AND sql NOT NULL";
}
/**
* {@inheritDoc}
*/
public function getCreateViewSQL(string $name, string $sql) : string
{
return 'CREATE VIEW ' . $name . ' AS ' . $sql;
}
/**
* {@inheritDoc}
*/
public function getDropViewSQL(string $name) : string
{
return 'DROP VIEW ' . $name;
}
/**
* {@inheritDoc}
*/
public function getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreignKey) : string
{
$query = parent::getAdvancedForeignKeyOptionsSQL($foreignKey);
......@@ -509,41 +443,26 @@ class SqlitePlatform extends AbstractPlatform
return $query;
}
/**
* {@inheritDoc}
*/
public function supportsIdentityColumns() : bool
{
return true;
}
/**
* {@inheritDoc}
*/
public function supportsColumnCollation() : bool
{
return true;
}
/**
* {@inheritDoc}
*/
public function supportsInlineColumnComments() : bool
{
return true;
}
/**
* {@inheritDoc}
*/
public function getName() : string
{
return 'sqlite';
}
/**
* {@inheritDoc}
*/
public function getTruncateTableSQL(string $tableName, bool $cascade = false) : string
{
$tableIdentifier = new Identifier($tableName);
......@@ -587,17 +506,11 @@ class SqlitePlatform extends AbstractPlatform
return 0;
}
/**
* {@inheritDoc}
*/
public function getForUpdateSql() : string
{
return '';
}
/**
* {@inheritDoc}
*/
public function getInlineColumnCommentSQL(?string $comment) : string
{
if ($comment === null || $comment === '') {
......@@ -612,9 +525,6 @@ class SqlitePlatform extends AbstractPlatform
return $this->getInlineColumnCommentSQL($comment);
}
/**
* {@inheritDoc}
*/
protected function initializeDoctrineTypeMappings() : void
{
$this->doctrineTypeMapping = [
......@@ -654,9 +564,6 @@ class SqlitePlatform extends AbstractPlatform
];
}
/**
* {@inheritDoc}
*/
protected function getReservedKeywordsClass() : string
{
return Keywords\SQLiteKeywords::class;
......@@ -710,9 +617,6 @@ class SqlitePlatform extends AbstractPlatform
return $sql;
}
/**
* {@inheritDoc}
*/
protected function doModifyLimitQuery(string $query, ?int $limit, int $offset) : string
{
if ($limit === null && $offset > 0) {
......@@ -730,9 +634,6 @@ class SqlitePlatform extends AbstractPlatform
return 'BLOB';
}
/**
* {@inheritDoc}
*/
public function getTemporaryTableName(string $tableName) : string
{
$tableName = str_replace('.', '__', $tableName);
......@@ -754,9 +655,6 @@ class SqlitePlatform extends AbstractPlatform
return true;
}
/**
* {@inheritDoc}
*/
public function supportsForeignKeyConstraints() : bool
{
return false;
......@@ -802,9 +700,6 @@ class SqlitePlatform extends AbstractPlatform
return parent::getCreateTableSQL($table, $createFlags);
}
/**
* {@inheritDoc}
*/
public function getListTableForeignKeysSQL(string $table, ?string $database = null) : string
{
$table = str_replace('.', '__', $table);
......
......@@ -38,9 +38,6 @@ class Connection extends \Doctrine\DBAL\Connection
/** @var int|null */
private $case;
/**
* {@inheritdoc}
*/
public function connect() : void
{
if ($this->isConnected()) {
......@@ -67,6 +64,7 @@ class Connection extends \Doctrine\DBAL\Connection
} else {
$params['portability'] &= self::PORTABILITY_OTHERVENDORS;
}
$this->portability = $params['portability'];
}
......@@ -107,9 +105,6 @@ class Connection extends \Doctrine\DBAL\Connection
return $stmt;
}
/**
* {@inheritdoc}
*/
public function prepare(string $sql) : DriverStatement
{
$stmt = new Statement(parent::prepare($sql), $this);
......@@ -118,9 +113,6 @@ class Connection extends \Doctrine\DBAL\Connection
return $stmt;
}
/**
* {@inheritdoc}
*/
public function query(string $sql) : ResultStatement
{
$connection = $this->getWrappedConnection();
......
......@@ -64,17 +64,11 @@ final class Statement implements IteratorAggregate, DriverStatement
$this->stmt->bindValue($param, $value, $type);
}
/**
* {@inheritdoc}
*/
public function closeCursor() : void
{
$this->stmt->closeCursor();
}
/**
* {@inheritdoc}
*/
public function columnCount() : int
{
return $this->stmt->columnCount();
......@@ -182,9 +176,6 @@ final class Statement implements IteratorAggregate, DriverStatement
return $value;
}
/**
* {@inheritdoc}
*/
public function rowCount() : int
{
assert($this->stmt instanceof DriverStatement);
......
......@@ -1274,6 +1274,7 @@ class QueryBuilder
$this->boundCounter++;
$placeHolder = ':dcValue' . $this->boundCounter;
}
$this->setParameter(substr($placeHolder, 1), $value, $type);
return $placeHolder;
......@@ -1323,6 +1324,7 @@ class QueryBuilder
if (array_key_exists($join->alias, $knownAliases)) {
throw NonUniqueAlias::new($join->alias, array_keys($knownAliases));
}
$sql .= ' ' . $join->type
. ' JOIN ' . $join->table . ' ' . $join->alias
. ' ON ' . ((string) $join->condition);
......
......@@ -6,7 +6,6 @@ namespace Doctrine\DBAL;
use Doctrine\DBAL\Exception\MissingArrayParameter;
use Doctrine\DBAL\Exception\MissingArrayParameterType;
use const PREG_OFFSET_CAPTURE;
use function array_fill;
use function array_key_exists;
use function array_merge;
......@@ -22,6 +21,7 @@ use function sprintf;
use function strlen;
use function strpos;
use function substr;
use const PREG_OFFSET_CAPTURE;
/**
* Utility class that parses sql statements with regard to types and parameters.
......@@ -171,8 +171,8 @@ class SQLParserUtils
$expandStr = $count ? implode(', ', array_fill(0, $count, '?')) : 'NULL';
$query = substr($query, 0, $needlePos) . $expandStr . substr($query, $needlePos + 1);
$paramOffset += ($count - 1); // Grows larger by number of parameters minus the replaced needle.
$queryOffset += (strlen($expandStr) - 1);
$paramOffset += $count - 1; // Grows larger by number of parameters minus the replaced needle.
$queryOffset += strlen($expandStr) - 1;
}
return [$query, $params, $types];
......@@ -190,10 +190,10 @@ class SQLParserUtils
if (! isset($arrayPositions[$paramName]) && ! isset($arrayPositions[':' . $paramName])) {
$pos += $queryOffset;
$queryOffset -= ($paramLen - 1);
$queryOffset -= $paramLen - 1;
$paramsOrd[] = $value;
$typesOrd[] = static::extractParam($paramName, $types, false, ParameterType::STRING);
$query = substr($query, 0, $pos) . '?' . substr($query, ($pos + $paramLen));
$query = substr($query, 0, $pos) . '?' . substr($query, $pos + $paramLen);
continue;
}
......@@ -207,8 +207,8 @@ class SQLParserUtils
}
$pos += $queryOffset;
$queryOffset += (strlen($expandStr) - $paramLen);
$query = substr($query, 0, $pos) . $expandStr . substr($query, ($pos + $paramLen));
$queryOffset += strlen($expandStr) - $paramLen;
$query = substr($query, 0, $pos) . $expandStr . substr($query, $pos + $paramLen);
}
return [$query, $paramsOrd, $typesOrd];
......
......@@ -46,11 +46,13 @@ abstract class AbstractAsset
$this->_quoted = true;
$name = $this->trimQuotes($name);
}
if (strpos($name, '.') !== false) {
$parts = explode('.', $name);
$this->_namespace = $parts[0];
$name = $parts[1];
}
$this->_name = $name;
}
......
......@@ -283,6 +283,7 @@ abstract class AbstractSchemaManager
if ($database === null) {
$database = $this->_conn->getDatabase();
}
$sql = $this->_platform->getListTableForeignKeysSQL($table, $database);
$tableForeignKeys = $this->_conn->fetchAll($sql);
......@@ -687,6 +688,7 @@ abstract class AbstractSchemaManager
if ($tableIndex['primary']) {
$keyName = 'primary';
}
$keyName = strtolower($keyName);
if (! isset($result[$keyName])) {
......@@ -901,9 +903,11 @@ abstract class AbstractSchemaManager
if (! isset($params['defaultTableOptions'])) {
$params['defaultTableOptions'] = [];
}
if (! isset($params['defaultTableOptions']['charset']) && isset($params['charset'])) {
$params['defaultTableOptions']['charset'] = $params['charset'];
}
$schemaConfig->setDefaultTableOptions($params['defaultTableOptions']);
return $schemaConfig;
......
......@@ -85,6 +85,7 @@ class Comparator
if (! isset($foreignKeysToTable[$foreignTable])) {
$foreignKeysToTable[$foreignTable] = [];
}
$foreignKeysToTable[$foreignTable][] = $foreignKey;
}
}
......@@ -112,6 +113,7 @@ class Comparator
if ($tableName !== strtolower($removedForeignKey->getForeignTableName())) {
continue;
}
unset($diff->changedTables[$localTableName]->removedForeignKeys[$key]);
}
}
......@@ -190,6 +192,7 @@ class Comparator
$tableDifferences->addedColumns[$columnName] = $column;
$changes++;
}
/* See if there are any removed fields in table 2 */
foreach ($table1Columns as $columnName => $column) {
// See if column is removed in table 2.
......@@ -226,6 +229,7 @@ class Comparator
$tableDifferences->addedIndexes[$indexName] = $index;
$changes++;
}
/* See if there are any removed indexes in table 2 */
foreach ($table1Indexes as $indexName => $index) {
// See if index is removed in table 2.
......@@ -436,6 +440,7 @@ class Comparator
if (($properties1['precision'] ?: 10) !== ($properties2['precision'] ?: 10)) {
$changedProperties[] = 'precision';
}
if ($properties1['scale'] !== $properties2['scale']) {
$changedProperties[] = 'scale';
}
......
......@@ -6,14 +6,15 @@ namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Platforms\DB2Platform;
use Doctrine\DBAL\Types\Type;
use const CASE_LOWER;
use function array_change_key_case;
use function assert;
use function is_resource;
use function preg_match;
use function str_replace;
use function strpos;
use function strtolower;
use function substr;
use const CASE_LOWER;
/**
* IBM Db2 Schema Manager.
......@@ -190,8 +191,8 @@ class DB2SchemaManager extends AbstractSchemaManager
{
$table = parent::listTableDetails($tableName);
/** @var DB2Platform $platform */
$platform = $this->_platform;
assert($platform instanceof DB2Platform);
$sql = $platform->getListTableCommentsSQL($tableName);
$tableOptions = $this->_conn->fetchAssoc($sql);
......
......@@ -7,7 +7,6 @@ namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Platforms\MariaDb1027Platform;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Types\Type;
use const CASE_LOWER;
use function array_change_key_case;
use function array_values;
use function assert;
......@@ -18,6 +17,7 @@ use function strpos;
use function strtok;
use function strtolower;
use function strtr;
use const CASE_LOWER;
/**
* Schema manager for the MySql RDBMS.
......@@ -75,11 +75,13 @@ class MySqlSchemaManager extends AbstractSchemaManager
} else {
$v['primary'] = false;
}
if (strpos($v['index_type'], 'FULLTEXT') !== false) {
$v['flags'] = ['FULLTEXT'];
} elseif (strpos($v['index_type'], 'SPATIAL') !== false) {
$v['flags'] = ['SPATIAL'];
}
$v['length'] = isset($v['sub_part']) ? (int) $v['sub_part'] : null;
$tableIndexRows[$k] = $v;
......@@ -136,6 +138,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
$scale = (int) $match[2];
$length = null;
}
break;
case 'tinytext':
$length = MySqlPlatform::LENGTH_LIMIT_TINYTEXT;
......@@ -191,6 +194,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
if (isset($tableColumn['characterset'])) {
$column->setPlatformOption('charset', $tableColumn['characterset']);
}
if (isset($tableColumn['collation'])) {
$column->setPlatformOption('collation', $tableColumn['collation']);
}
......@@ -248,6 +252,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
if (! isset($value['delete_rule']) || $value['delete_rule'] === 'RESTRICT') {
$value['delete_rule'] = null;
}
if (! isset($value['update_rule']) || $value['update_rule'] === 'RESTRICT') {
$value['update_rule'] = null;
}
......@@ -261,6 +266,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
'onUpdate' => $value['update_rule'],
];
}
$list[$value['constraint_name']]['local'][] = $value['column_name'];
$list[$value['constraint_name']]['foreign'][] = $value['referenced_column_name'];
}
......@@ -282,15 +288,12 @@ class MySqlSchemaManager extends AbstractSchemaManager
return $result;
}
/**
* {@inheritdoc}
*/
public function listTableDetails(string $tableName) : Table
{
$table = parent::listTableDetails($tableName);
/** @var MySqlPlatform $platform */
$platform = $this->_platform;
assert($platform instanceof MySqlPlatform);
$sql = $platform->getListTableMetadataSQL($tableName);
$tableOptions = $this->_conn->fetchAssoc($sql);
......
......@@ -9,7 +9,6 @@ use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use const CASE_LOWER;
use function array_change_key_case;
use function array_filter;
use function array_keys;
......@@ -26,6 +25,7 @@ use function strlen;
use function strpos;
use function strtolower;
use function trim;
use const CASE_LOWER;
/**
* PostgreSQL Schema Manager.
......@@ -97,9 +97,6 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
});
}
/**
* {@inheritdoc}
*/
public function dropDatabase(string $database) : void
{
try {
......@@ -140,6 +137,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
if (preg_match('(ON UPDATE ([a-zA-Z0-9]+( (NULL|ACTION|DEFAULT))?))', $tableForeignKey['condef'], $match)) {
$onUpdate = $match[1];
}
if (preg_match('(ON DELETE ([a-zA-Z0-9]+( (NULL|ACTION|DEFAULT))?))', $tableForeignKey['condef'], $match)) {
$onDelete = $match[1];
}
......@@ -413,6 +411,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$scale = (int) $match[2];
$length = null;
}
break;
case 'year':
$length = null;
......@@ -487,8 +486,8 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
{
$table = parent::listTableDetails($tableName);
/** @var PostgreSqlPlatform $platform */
$platform = $this->_platform;
assert($platform instanceof PostgreSqlPlatform);
$sql = $platform->getListTableMetadataSQL($tableName);
$tableOptions = $this->_conn->fetchAssoc($sql);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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