Skip to content

Commit

Permalink
Merge tag 'v2.9.3' into oracle122
Browse files Browse the repository at this point in the history
Release v2.9.3

[![Build Status](https://travis-ci.org/doctrine/dbal.svg?branch=v2.9.3)](https://travis-ci.org/doctrine/dbal)

This release fixes regressions introduced in previous releases and other bugs.

- Total issues resolved: **5**
- Total pull requests resolved: **14**
- Total contributors: **9**

**Regressions**

 - [3686: Fixed query result caching when `FetchMode::COLUMN` is used](doctrine#3686) thanks to @morozov and @Junker

 - [3456: Compare type class when comparing columns.](doctrine#3456) thanks to @garret-gunter and @cs278

**Other bugs**

 - [3679: fix begin trasaction after reconnect](doctrine#3679) thanks to @kalinin-k-a

 - [3547: Default column expressions do not work on SQL Server](doctrine#3547) thanks to @morozov

 - [3420: Index length can be a `string`: ensure that it is an integer when read by the `MySqlSchemaManager`](doctrine#3420) thanks to @leofeyer

**CI improvements and maintenance**

 - [3702: Updated SQL Server extensions to fix build failures on PHP 7.4](doctrine#3702) thanks to @morozov

 - [3662: Marked connection exception test incomplete on MySQL 8](doctrine#3662) thanks to @morozov

 - [3622: Switched from ibmcom/db2express-c to ibmcom/db2](doctrine#3622) thanks to @morozov

 - [3465: Replaced MySQL 5.7 installed from a PPA with an official Docker image](doctrine#3465) thanks to @morozov

 - [3454: CI: Test against PHP 7.4snapshot instead of nightly (8.0)](doctrine#3454) thanks to @Majkl578

 - [3452: Fixed AppVeyor build configuration and the issue on SQL Server](doctrine#3452) thanks to @morozov and @Majkl578

 - [3447: Replaced custom docker image for PostgreSQL with the official one](doctrine#3447) thanks to @morozov

 - [3407: CI: Test against MySQL 8.0 on Travis](doctrine#3407) thanks to @morozov

**PHP 7.4 support**

 - [3642: Fixed test failures on PHP 7.4](doctrine#3642) thanks to @morozov

# gpg: Signature made Sat Nov  2 23:20:42 2019
# gpg:                using RSA key 374EADAF543AE995
# gpg: Can't check signature: public key not found
  • Loading branch information
rgrellmann committed Apr 22, 2020
2 parents 5d827b5 + 7345cd5 commit 65da389
Show file tree
Hide file tree
Showing 41 changed files with 610 additions and 236 deletions.
14 changes: 11 additions & 3 deletions .appveyor.yml
Expand Up @@ -131,17 +131,25 @@ before_test:
}
test_script:
- cd C:\projects\dbal
- ps: >-
if ($env:db_version) {
$env:phpunit_config = "tests\appveyor\$($env:db).$($env:db_version).$($env:driver).appveyor.xml"
} else {
$env:phpunit_config = "tests\appveyor\$($env:db).$($env:driver).appveyor.xml"
}
- ps: >-
if ($env:coverage -eq "yes") {
vendor\bin\phpunit -c $($env:phpunit_config) --coverage-clover clover.xml
appveyor-retry ocular code-coverage:upload --format=php-clover clover.xml
} else {
vendor\bin\phpunit -c $($env:phpunit_config)
}
if ($LastExitCode -ne 0) {
$host.SetShouldExit($LastExitCode)
}
after_test:
- ps: >-
if ($env:coverage -eq "yes") {
appveyor-retry ocular code-coverage:upload --format=php-clover clover.xml
}
23 changes: 10 additions & 13 deletions .travis.yml
Expand Up @@ -41,9 +41,6 @@ after_script:
fi
jobs:
allow_failures:
- php: nightly

include:
- stage: Test
php: 7.1
Expand Down Expand Up @@ -117,7 +114,7 @@ jobs:
env: DB=mysql COVERAGE=yes
- stage: Test
php: 7.2
env: DB=mysql MYSQL_VERSION=5.7 COVERAGE=yes
env: DB=mysql.docker MYSQL_VERSION=5.7 COVERAGE=yes
sudo: required
before_script:
- bash ./tests/travis/install-mysql-5.7.sh
Expand All @@ -133,7 +130,7 @@ jobs:
env: DB=mysqli COVERAGE=yes
- stage: Test
php: 7.2
env: DB=mysqli MYSQL_VERSION=5.7 COVERAGE=yes
env: DB=mysqli.docker MYSQL_VERSION=5.7 COVERAGE=yes
sudo: required
before_script:
- bash ./tests/travis/install-mysql-5.7.sh
Expand Down Expand Up @@ -319,42 +316,42 @@ jobs:
- bash ./tests/travis/install-mssql-pdo_sqlsrv.sh
- bash ./tests/travis/install-mssql.sh
- stage: Test
php: nightly
php: 7.4snapshot
env: DB=mysql MYSQL_VERSION=8.0
dist: xenial
sudo: required
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
- stage: Test
php: nightly
php: 7.4snapshot
env: DB=mysqli MYSQL_VERSION=8.0
dist: xenial
sudo: required
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
- stage: Test
php: nightly
php: 7.4snapshot
env: DB=mariadb MARIADB_VERSION=10.3
addons:
mariadb: 10.3
- stage: Test
php: nightly
php: 7.4snapshot
env: DB=mariadb.mysqli MARIADB_VERSION=10.3
addons:
mariadb: 10.3
- stage: Test
php: nightly
php: 7.4snapshot
env: DB=pgsql POSTGRESQL_VERSION=11.0
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-postgres-11.sh
- stage: Test
php: nightly
php: 7.4snapshot
env: DB=sqlite
- stage: Test
php: nightly
php: 7.4snapshot
env: DB=sqlsrv
sudo: required
services:
Expand All @@ -363,7 +360,7 @@ jobs:
- bash ./tests/travis/install-mssql-sqlsrv.sh
- bash ./tests/travis/install-mssql.sh
- stage: Test
php: nightly
php: 7.4snapshot
env: DB=pdo_sqlsrv
sudo: required
services:
Expand Down
2 changes: 1 addition & 1 deletion docs/en/index.rst
Expand Up @@ -10,7 +10,7 @@ Getting Help
If this documentation is not helping to answer questions you have about the
Doctrine DBAL, don't panic. You can get help from different sources:

- Gitter chat room `#doctrine/dbal <https://gitter.im/doctrine/dbal>`_
- Slack chat room `#dbal <https://www.doctrine-project.org/slack>`_
- On `Stack Overflow <http://stackoverflow.com/questions/tagged/doctrine-dbal>`_
- The `Doctrine Mailing List <http://groups.google.com/group/doctrine-user>`_
- Report a bug on `GitHub <https://github.com/doctrine/dbal/issues>`_.
Expand Down
13 changes: 12 additions & 1 deletion lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
Expand Up @@ -166,7 +166,18 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX
*/
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
{
return $this->statement->fetchAll($fetchMode, $fetchArgument, $ctorArgs);
$data = $this->statement->fetchAll($fetchMode, $fetchArgument, $ctorArgs);

if ($fetchMode === FetchMode::COLUMN) {
foreach ($data as $key => $value) {
$data[$key] = [$value];
}
}

$this->data = $data;
$this->emptied = true;

return $this->data;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/DBAL/Connection.php
Expand Up @@ -356,6 +356,8 @@ public function connect()
$this->_conn = $this->_driver->connect($this->params, $user, $password, $driverOptions);
$this->isConnected = true;

$this->transactionNestingLevel = 0;

if ($this->autoCommit === false) {
$this->beginTransaction();
}
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php
Expand Up @@ -354,6 +354,8 @@ public function query()

$statement = $this->_conn->query(...$args);

$statement->setFetchMode($this->defaultFetchMode);

if ($logger) {
$logger->stopQuery();
}
Expand Down
6 changes: 5 additions & 1 deletion lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php
Expand Up @@ -7,12 +7,16 @@
class OCI8Exception extends AbstractDriverException
{
/**
* @param mixed[] $error
* @param mixed[]|false $error
*
* @return \Doctrine\DBAL\Driver\OCI8\OCI8Exception
*/
public static function fromErrorInfo($error)
{
if ($error === false) {
return new self('Database error occurred but no error information was retrieved from the driver.');
}

return new self($error['message'], null, $error['code']);
}
}
11 changes: 8 additions & 3 deletions lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php
Expand Up @@ -59,6 +59,9 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
/** @var resource The prepared SQL statement to execute. */
private $stmt;

/** @var mixed[] The references to bound parameter values. */
private $boundValues = [];

/**
* Prepares given statement for given connection.
*
Expand Down Expand Up @@ -108,6 +111,8 @@ public function bindParam($column, &$variable, $type = ParameterType::STRING, $l
throw new SQLAnywhereException('Unknown type: ' . $type);
}

$this->boundValues[$column] =& $variable;

if (! sasql_stmt_bind_param_ex($this->stmt, $column - 1, $variable, $type, $variable === null)) {
throw SQLAnywhereException::fromSQLAnywhereError($this->conn, $this->stmt);
}
Expand Down Expand Up @@ -248,19 +253,19 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n

switch ($fetchMode) {
case FetchMode::CUSTOM_OBJECT:
while ($row = $this->fetch(...func_get_args())) {
while (($row = $this->fetch(...func_get_args())) !== false) {
$rows[] = $row;
}
break;

case FetchMode::COLUMN:
while ($row = $this->fetchColumn()) {
while (($row = $this->fetchColumn()) !== false) {
$rows[] = $row;
}
break;

default:
while ($row = $this->fetch($fetchMode)) {
while (($row = $this->fetch($fetchMode)) !== false) {
$rows[] = $row;
}
}
Expand Down
23 changes: 9 additions & 14 deletions lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php
Expand Up @@ -1308,25 +1308,20 @@ protected function _getTransactionIsolationLevelSQL($level)
*/
protected function doModifyLimitQuery($query, $limit, $offset)
{
$limitOffsetClause = '';
$limitOffsetClause = $this->getTopClauseSQL($limit, $offset);

if ($limit > 0) {
$limitOffsetClause = 'TOP ' . $limit . ' ';
}
return $limitOffsetClause === ''
? $query
: preg_replace('/^\s*(SELECT\s+(DISTINCT\s+)?)/i', '\1' . $limitOffsetClause . ' ', $query);
}

private function getTopClauseSQL(?int $limit, ?int $offset) : string
{
if ($offset > 0) {
if ($limit === 0) {
$limitOffsetClause = 'TOP ALL ';
}

$limitOffsetClause .= 'START AT ' . ($offset + 1) . ' ';
}

if ($limitOffsetClause) {
return preg_replace('/^\s*(SELECT\s+(DISTINCT\s+)?)/i', '\1' . $limitOffsetClause, $query);
return sprintf('TOP %s START AT %d', $limit ?? 'ALL', $offset + 1);
}

return $query;
return $limit === null ? '' : 'TOP ' . $limit;
}

/**
Expand Down
31 changes: 0 additions & 31 deletions lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
Expand Up @@ -10,7 +10,6 @@
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types;
use InvalidArgumentException;
use function array_merge;
use function array_unique;
Expand Down Expand Up @@ -1591,36 +1590,6 @@ public function getBlobTypeDeclarationSQL(array $field)
return 'VARBINARY(MAX)';
}

/**
* {@inheritDoc}
*/
public function getDefaultValueDeclarationSQL($field)
{
if (! isset($field['default'])) {
return empty($field['notnull']) ? ' NULL' : '';
}

if (! isset($field['type'])) {
return " DEFAULT '" . $field['default'] . "'";
}

$type = $field['type'];

if ($type instanceof Types\PhpIntegerMappingType) {
return ' DEFAULT ' . $field['default'];
}

if ($type instanceof Types\PhpDateTimeMappingType && $field['default'] === $this->getCurrentTimestampSQL()) {
return ' DEFAULT ' . $this->getCurrentTimestampSQL();
}

if ($type instanceof Types\BooleanType) {
return " DEFAULT '" . $this->convertBooleans($field['default']) . "'";
}

return " DEFAULT '" . $field['default'] . "'";
}

/**
* {@inheritdoc}
*
Expand Down
9 changes: 7 additions & 2 deletions lib/Doctrine/DBAL/Schema/Comparator.php
Expand Up @@ -11,6 +11,7 @@
use function array_shift;
use function array_unique;
use function count;
use function get_class;
use function strtolower;

/**
Expand Down Expand Up @@ -417,7 +418,11 @@ public function diffColumn(Column $column1, Column $column2)

$changedProperties = [];

foreach (['type', 'notnull', 'unsigned', 'autoincrement'] as $property) {
if (get_class($properties1['type']) !== get_class($properties2['type'])) {
$changedProperties[] = 'type';
}

foreach (['notnull', 'unsigned', 'autoincrement'] as $property) {
if ($properties1[$property] === $properties2[$property]) {
continue;
}
Expand All @@ -435,7 +440,7 @@ public function diffColumn(Column $column1, Column $column2)
// Null values need to be checked additionally as they tell whether to create or drop a default value.
// null != 0, null != false, null != '' etc. This affects platform's table alteration SQL generation.
if (($properties1['default'] === null) !== ($properties2['default'] === null)
|| (string) $properties1['default'] !== (string) $properties2['default']) {
|| $properties1['default'] != $properties2['default']) {
$changedProperties[] = 'default';
}

Expand Down
18 changes: 18 additions & 0 deletions lib/Doctrine/DBAL/Schema/Index.php
Expand Up @@ -4,6 +4,7 @@

use Doctrine\DBAL\Platforms\AbstractPlatform;
use InvalidArgumentException;
use function array_filter;
use function array_keys;
use function array_map;
use function array_search;
Expand Down Expand Up @@ -211,6 +212,10 @@ public function isFullfilledBy(Index $other)
return false;
}

if (! $this->hasSameColumnLengths($other)) {
return false;
}

if (! $this->isUnique() && ! $this->isPrimary()) {
// this is a special case: If the current key is neither primary or unique, any unique or
// primary key will always have the same effect for the index and there cannot be any constraint
Expand Down Expand Up @@ -336,4 +341,17 @@ private function samePartialIndex(Index $other)

return ! $this->hasOption('where') && ! $other->hasOption('where');
}

/**
* Returns whether the index has the same column lengths as the other
*/
private function hasSameColumnLengths(self $other) : bool
{
$filter = static function (?int $length) : bool {
return $length !== null;
};

return array_filter($this->options['lengths'] ?? [], $filter)
=== array_filter($other->options['lengths'] ?? [], $filter);
}
}

0 comments on commit 65da389

Please sign in to comment.