Unverified Commit e82ad5d1 authored by Sergei Morozov's avatar Sergei Morozov

Merge branch '2.10.x' into 2.11.x

parents f9a0563f d7f22923
......@@ -21,7 +21,7 @@ before_commands:
tools:
external_code_coverage:
timeout: 3600
runs: 30 # 25x Travis (jobs with COVERAGE=yes) + 3x AppVeyor (jobs with coverage=yes) + 2x ContinuousPHP
runs: 28 # 23x Travis (jobs with COVERAGE=yes) + 3x AppVeyor (jobs with coverage=yes) + 2x ContinuousPHP
filter:
excluded_paths:
......
language: php
sudo: false
dist: trusty
dist: xenial
cache:
directories:
......@@ -15,7 +14,11 @@ before_install:
fi
before_script:
- if [[ "$DB" == "mysql" || "$DB" == "mysqli" || "$DB" == *"mariadb"* ]]; then mysql < tests/travis/create-mysql-schema.sql; fi;
- |
if [[ -n "$IMAGE" ]]
then
bash ./tests/travis/docker-run-mysql-or-mariadb.sh
fi
install:
- travis_retry composer -n install --prefer-dist
......@@ -54,36 +57,20 @@ jobs:
- stage: Test
php: 7.2
env: DB=mysql.docker MYSQL_VERSION=8.0
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
env: DB=mysql.docker IMAGE=mysql:8.0
- stage: Test
php: 7.2
env: DB=mysqli.docker MYSQL_VERSION=8.0
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
env: DB=mysqli.docker IMAGE=mysql:8.0
- stage: Test
php: 7.2
env: DB=mariadb MARIADB_VERSION=10.3
addons:
mariadb: 10.3
env: DB=mariadb.docker IMAGE=mariadb:10.3
- stage: Test
php: 7.2
env: DB=mariadb.mysqli MARIADB_VERSION=10.3
addons:
mariadb: 10.3
env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.3
- stage: Test
php: 7.2
env: DB=pgsql POSTGRESQL_VERSION=11.0
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-postgres-11.sh
- stage: Test
......@@ -93,8 +80,6 @@ jobs:
php: 7.2
env: DB=sqlsrv
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-sqlsrv-dependencies.sh
- bash ./tests/travis/install-mssql-sqlsrv.sh
......@@ -103,87 +88,48 @@ jobs:
php: 7.2
env: DB=pdo_sqlsrv
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-sqlsrv-dependencies.sh
- bash ./tests/travis/install-mssql-pdo_sqlsrv.sh
- bash ./tests/travis/install-mssql.sh
- stage: Test
php: 7.3
env: DB=mysql COVERAGE=yes
env: DB=mysql.docker IMAGE=mysql:5.7 COVERAGE=yes
- stage: Test
php: 7.3
env: DB=mysql.docker MYSQL_VERSION=5.7 COVERAGE=yes
sudo: required
before_script:
- bash ./tests/travis/install-mysql-5.7.sh
env: DB=mysql.docker IMAGE=mysql:8.0 COVERAGE=yes
- stage: Test
php: 7.3
env: DB=mysql.docker MYSQL_VERSION=8.0 COVERAGE=yes
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
env: DB=mysqli.docker IMAGE=mysql:5.7 COVERAGE=yes
- stage: Test
php: 7.3
env: DB=mysqli COVERAGE=yes
env: DB=mysqli.docker IMAGE=mysql:8.0 COVERAGE=yes
- stage: Test
php: 7.3
env: DB=mysqli.docker MYSQL_VERSION=5.7 COVERAGE=yes
sudo: required
before_script:
- bash ./tests/travis/install-mysql-5.7.sh
env: DB=mariadb.docker IMAGE=mariadb:10.0 COVERAGE=yes
- stage: Test
php: 7.3
env: DB=mysqli.docker MYSQL_VERSION=8.0 COVERAGE=yes
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
env: DB=mariadb.docker IMAGE=mariadb:10.1 COVERAGE=yes
- stage: Test
php: 7.3
env: DB=mariadb MARIADB_VERSION=10.0 COVERAGE=yes
addons:
mariadb: 10.0
env: DB=mariadb.docker IMAGE=mariadb:10.2 COVERAGE=yes
- stage: Test
php: 7.3
env: DB=mariadb MARIADB_VERSION=10.1 COVERAGE=yes
addons:
mariadb: 10.1
env: DB=mariadb.docker IMAGE=mariadb:10.3 COVERAGE=yes
- stage: Test
php: 7.3
env: DB=mariadb MARIADB_VERSION=10.2 COVERAGE=yes
addons:
mariadb: 10.2
env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.0 COVERAGE=yes
- stage: Test
php: 7.3
env: DB=mariadb MARIADB_VERSION=10.3 COVERAGE=yes
addons:
mariadb: 10.3
env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.1 COVERAGE=yes
- stage: Test
php: 7.3
env: DB=mariadb.mysqli MARIADB_VERSION=10.0 COVERAGE=yes
addons:
mariadb: 10.0
env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.2 COVERAGE=yes
- stage: Test
php: 7.3
env: DB=mariadb.mysqli MARIADB_VERSION=10.1 COVERAGE=yes
addons:
mariadb: 10.1
- stage: Test
php: 7.3
env: DB=mariadb.mysqli MARIADB_VERSION=10.2 COVERAGE=yes
addons:
mariadb: 10.2
- stage: Test
php: 7.3
env: DB=mariadb.mysqli MARIADB_VERSION=10.3 COVERAGE=yes
addons:
mariadb: 10.3
env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.3 COVERAGE=yes
- stage: Test
dist: trusty
php: 7.3
env: DB=pgsql POSTGRESQL_VERSION=9.2 COVERAGE=yes
services:
......@@ -191,6 +137,7 @@ jobs:
addons:
postgresql: "9.2"
- stage: Test
dist: trusty
php: 7.3
env: DB=pgsql POSTGRESQL_VERSION=9.3 COVERAGE=yes
services:
......@@ -200,48 +147,36 @@ jobs:
- stage: Test
php: 7.3
env: DB=pgsql POSTGRESQL_VERSION=9.4 COVERAGE=yes
services:
- postgresql
addons:
postgresql: "9.4"
- stage: Test
php: 7.3
env: DB=pgsql POSTGRESQL_VERSION=9.5 COVERAGE=yes
services:
- postgresql
addons:
postgresql: "9.5"
- stage: Test
php: 7.3
env: DB=pgsql POSTGRESQL_VERSION=9.6 COVERAGE=yes
services:
- postgresql
addons:
postgresql: "9.6"
- stage: Test
php: 7.3
env: DB=pgsql POSTGRESQL_VERSION=10.0 COVERAGE=yes
sudo: required
services:
- postgresql
addons:
postgresql: "9.6"
postgresql: "10"
before_script:
- bash ./tests/travis/install-postgres-10.sh
- stage: Test
php: 7.3
env: DB=pgsql POSTGRESQL_VERSION=11.0 COVERAGE=yes
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-postgres-11.sh
- stage: Test
php: 7.3
env: DB=sqlsrv COVERAGE=yes
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-sqlsrv-dependencies.sh
- bash ./tests/travis/install-mssql-sqlsrv.sh
......@@ -250,8 +185,6 @@ jobs:
php: 7.3
env: DB=pdo_sqlsrv COVERAGE=yes
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-sqlsrv-dependencies.sh
- bash ./tests/travis/install-mssql-pdo_sqlsrv.sh
......@@ -260,8 +193,6 @@ jobs:
php: 7.3
env: DB=ibm_db2 COVERAGE=yes
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-db2.sh
- bash ./tests/travis/install-db2-ibm_db2.sh
......@@ -271,58 +202,38 @@ jobs:
install:
- travis_retry composer update --prefer-dist --prefer-lowest
- stage: Test
php: 7.4snapshot
env: DB=mysql.docker MYSQL_VERSION=8.0
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
php: 7.4
env: DB=mysql.docker IMAGE=mysql:8.0
- stage: Test
php: 7.4snapshot
env: DB=mysqli.docker MYSQL_VERSION=8.0
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
php: 7.4
env: DB=mysqli.docker IMAGE=mysql:8.0
- stage: Test
php: 7.4snapshot
env: DB=mariadb MARIADB_VERSION=10.3
addons:
mariadb: 10.3
php: 7.4
env: DB=mariadb.docker IMAGE=mariadb:10.3
- stage: Test
php: 7.4snapshot
env: DB=mariadb.mysqli MARIADB_VERSION=10.3
addons:
mariadb: 10.3
php: 7.4
env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.3
- stage: Test
php: 7.4snapshot
php: 7.4
env: DB=pgsql POSTGRESQL_VERSION=11.0
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-postgres-11.sh
- stage: Test
php: 7.4snapshot
php: 7.4
env: DB=sqlite
- stage: Test
php: 7.4snapshot
php: 7.4
env: DB=sqlsrv
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-sqlsrv-dependencies.sh
- bash ./tests/travis/install-mssql-sqlsrv.sh
- bash ./tests/travis/install-mssql.sh
- stage: Test
php: 7.4snapshot
php: 7.4
env: DB=pdo_sqlsrv
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-sqlsrv-dependencies.sh
- bash ./tests/travis/install-mssql-pdo_sqlsrv.sh
......
# Doctrine DBAL
| [Master][Master] | [2.9][2.9] | [Develop][develop] |
|:----------------:|:----------:|:------------------:|
| [![Build status][Master image]][Master] | [![Build status][2.9 image]][2.9] | [![Build status][develop image]][develop] |
| [![Build Status][ContinuousPHP image]][ContinuousPHP] | [![Build Status][ContinuousPHP 2.9 image]][ContinuousPHP] | [![Build Status][ContinuousPHP develop image]][ContinuousPHP] |
| [![Code Coverage][Coverage image]][Scrutinizer Master] | [![Code Coverage][Coverage 2.9 image]][Scrutinizer 2.9] | [![Code Coverage][Coverage develop image]][Scrutinizer develop] |
| [![Code Quality][Quality image]][Scrutinizer Master] | [![Code Quality][Quality 2.9 image]][Scrutinizer 2.9] | [![Code Quality][Quality develop image]][Scrutinizer develop] |
| [![AppVeyor][AppVeyor master image]][AppVeyor master] | [![AppVeyor][AppVeyor 2.9 image]][AppVeyor 2.9] | [![AppVeyor][AppVeyor develop image]][AppVeyor develop] |
| [Master][Master] | [2.10][2.10] |
|:----------------:|:----------:|
| [![Build status][Master image]][Master] | [![Build status][2.10 image]][2.10] |
| [![Build Status][ContinuousPHP image]][ContinuousPHP] | [![Build Status][ContinuousPHP 2.10 image]][ContinuousPHP] |
| [![Code Coverage][Coverage image]][Scrutinizer Master] | [![Code Coverage][Coverage 2.10 image]][Scrutinizer 2.10] |
| [![Code Quality][Quality image]][Scrutinizer Master] | [![Code Quality][Quality 2.10 image]][Scrutinizer 2.10] |
| [![AppVeyor][AppVeyor master image]][AppVeyor master] | [![AppVeyor][AppVeyor 2.10 image]][AppVeyor 2.10] |
Powerful database abstraction layer with many features for database schema introspection, schema management and PDO abstraction.
......@@ -26,21 +26,11 @@ Powerful database abstraction layer with many features for database schema intro
[AppVeyor master image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/master?svg=true
[ContinuousPHP]: https://continuousphp.com/git-hub/doctrine/dbal
[2.9 image]: https://img.shields.io/travis/doctrine/dbal/2.9.svg?style=flat-square
[Coverage 2.9 image]: https://img.shields.io/scrutinizer/coverage/g/doctrine/dbal/2.9.svg?style=flat-square
[Quality 2.9 image]: https://img.shields.io/scrutinizer/g/doctrine/dbal/2.9.svg?style=flat-square
[ContinuousPHP 2.9 image]: https://img.shields.io/continuousphp/git-hub/doctrine/dbal/2.9.svg?style=flat-square
[2.9]: https://github.com/doctrine/dbal/tree/2.9
[Scrutinizer 2.9]: https://scrutinizer-ci.com/g/doctrine/dbal/?branch=2.9
[AppVeyor 2.9]: https://ci.appveyor.com/project/doctrine/dbal/branch/2.9
[AppVeyor 2.9 image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/2.9?svg=true
[develop]: https://github.com/doctrine/dbal/tree/develop
[develop image]: https://img.shields.io/travis/doctrine/dbal/develop.svg?style=flat-square
[Coverage develop image]: https://img.shields.io/scrutinizer/coverage/g/doctrine/dbal/develop.svg?style=flat-square
[Quality develop image]: https://img.shields.io/scrutinizer/g/doctrine/dbal/develop.svg?style=flat-square
[ContinuousPHP develop image]: https://img.shields.io/continuousphp/git-hub/doctrine/dbal/develop.svg?style=flat-square
[develop]: https://github.com/doctrine/dbal/tree/develop
[Scrutinizer develop]: https://scrutinizer-ci.com/g/doctrine/dbal/?branch=develop
[AppVeyor develop]: https://ci.appveyor.com/project/doctrine/dbal/branch/develop
[AppVeyor develop image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/develop?svg=true
[2.10 image]: https://img.shields.io/travis/doctrine/dbal/2.10.x.svg?style=flat-square
[Coverage 2.10 image]: https://img.shields.io/scrutinizer/coverage/g/doctrine/dbal/2.10.x.svg?style=flat-square
[Quality 2.10 image]: https://img.shields.io/scrutinizer/g/doctrine/dbal/2.10.x.svg?style=flat-square
[ContinuousPHP 2.10 image]: https://img.shields.io/continuousphp/git-hub/doctrine/dbal/2.10.x.svg?style=flat-square
[2.10]: https://github.com/doctrine/dbal/tree/2.10.x
[Scrutinizer 2.10]: https://scrutinizer-ci.com/g/doctrine/dbal/?branch=2.10.x
[AppVeyor 2.10]: https://ci.appveyor.com/project/doctrine/dbal/branch/2.10.x
[AppVeyor 2.10 image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/2.10.x?svg=true
......@@ -160,7 +160,7 @@ following code in Doctrine:
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Id\TableGenerator;
$conn = DriverManager::getConnection(/**..**); // connection 1
$conn = DriverManager::getConnection(/**..**/); // connection 1
// creating the TableGenerator automatically opens a second connection.
$tableGenerator = new TableGenerator($conn, "sequences_tbl_name");
......
......@@ -88,20 +88,7 @@ final class DriverManager
*
* $params must contain at least one of the following.
*
* Either 'driver' with one of the following values:
*
* pdo_mysql
* pdo_sqlite
* pdo_pgsql
* pdo_oci (unstable)
* pdo_sqlsrv
* pdo_sqlsrv
* mysqli
* sqlanywhere
* sqlsrv
* ibm_db2 (unstable)
* drizzle_pdo_mysql
*
* Either 'driver' with one of the array keys of {@link $_driverMap},
* OR 'driverClass' that contains the full class name (with namespace) of the
* driver class to instantiate.
*
......
......@@ -12,7 +12,7 @@ class DebugStack implements SQLLogger
/**
* Executed SQL queries.
*
* @var mixed[][]
* @var array<int, array<string, mixed>>
*/
public $queries = [];
......
......@@ -367,7 +367,7 @@ SQL
[$schema, $table] = explode('.', $table);
$schema = $this->quoteStringLiteral($schema);
} else {
$schema = "ANY(string_to_array((select replace(replace(setting,'\"\$user\"',user),' ','') from pg_catalog.pg_settings where name = 'search_path'),','))";
$schema = 'ANY(current_schemas(false))';
}
$table = new Identifier($table);
......
......@@ -3,7 +3,7 @@
namespace Doctrine\DBAL\Query;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Query\Expression\CompositeExpression;
use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
......@@ -118,9 +118,9 @@ class QueryBuilder
private $firstResult = null;
/**
* The maximum number of results to retrieve.
* The maximum number of results to retrieve or NULL to retrieve all results.
*
* @var int
* @var int|null
*/
private $maxResults = null;
......@@ -198,7 +198,7 @@ class QueryBuilder
* Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate}
* for insert, update and delete statements.
*
* @return Statement|int
* @return ResultStatement|int
*/
public function execute()
{
......@@ -367,7 +367,6 @@ class QueryBuilder
/**
* Gets the position of the first result the query object was set to retrieve (the "offset").
* Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder.
*
* @return int The position of the first result.
*/
......@@ -379,7 +378,7 @@ class QueryBuilder
/**
* Sets the maximum number of results to retrieve (the "limit").
*
* @param int $maxResults The maximum number of results to retrieve.
* @param int|null $maxResults The maximum number of results to retrieve or NULL to retrieve all results.
*
* @return $this This QueryBuilder instance.
*/
......@@ -393,7 +392,7 @@ class QueryBuilder
/**
* Gets the maximum number of results the query object was set to retrieve (the "limit").
* Returns NULL if {@link setMaxResults} was not applied to this query builder.
* Returns NULL if all results will be returned.
*
* @return int The maximum number of results.
*/
......@@ -1340,8 +1339,10 @@ class QueryBuilder
throw QueryException::nonUniqueAlias($join['joinAlias'], array_keys($knownAliases));
}
$sql .= ' ' . strtoupper($join['joinType'])
. ' JOIN ' . $join['joinTable'] . ' ' . $join['joinAlias']
. ' ON ' . ((string) $join['joinCondition']);
. ' JOIN ' . $join['joinTable'] . ' ' . $join['joinAlias'];
if ($join['joinCondition'] !== null) {
$sql .= ' ON ' . $join['joinCondition'];
}
$knownAliases[$join['joinAlias']] = true;
}
......
......@@ -4,7 +4,9 @@ namespace Doctrine\DBAL;
use const PREG_OFFSET_CAPTURE;
use function array_fill;
use function array_fill_keys;
use function array_key_exists;
use function array_keys;
use function array_merge;
use function array_slice;
use function array_values;
......@@ -31,9 +33,9 @@ class SQLParserUtils
public const POSITIONAL_TOKEN = '\?';
public const NAMED_TOKEN = '(?<!:):[a-zA-Z_][a-zA-Z0-9_]*';
// Quote characters within string literals can be preceded by a backslash.
public const ESCAPED_SINGLE_QUOTED_TEXT = "(?:'(?:\\\\\\\\)+'|'(?:[^'\\\\]|\\\\'?|'')*')";
public const ESCAPED_DOUBLE_QUOTED_TEXT = '(?:"(?:\\\\\\\\)+"|"(?:[^"\\\\]|\\\\"?)*")';
public const ESCAPED_BACKTICK_QUOTED_TEXT = '(?:`(?:\\\\\\\\)+`|`(?:[^`\\\\]|\\\\`?)*`)';
public const ESCAPED_SINGLE_QUOTED_TEXT = "(?:'(?:\\\\)+'|'(?:[^'\\\\]|\\\\'?|'')*')";
public const ESCAPED_DOUBLE_QUOTED_TEXT = '(?:"(?:\\\\)+"|"(?:[^"\\\\]|\\\\"?)*")';
public const ESCAPED_BACKTICK_QUOTED_TEXT = '(?:`(?:\\\\)+`|`(?:[^`\\\\]|\\\\`?)*`)';
/**#@-*/
private const ESCAPED_BRACKET_QUOTED_TEXT = '(?<!\b(?i:ARRAY))\[(?:[^\]])*\]';
......@@ -131,6 +133,10 @@ class SQLParserUtils
$bindIndex = -1;
if ($isPositional) {
// make sure that $types has the same keys as $params
// to allow omitting parameters with unspecified types
$types += array_fill_keys(array_keys($params), null);
ksort($params);
ksort($types);
}
......
......@@ -233,7 +233,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
$position = strrpos($name, '.');
if ($position !== false) {
$name = substr($name, $position);
$name = substr($name, $position + 1);
}
return strtolower($name);
......
......@@ -26,11 +26,11 @@ class ConversionException extends DBALException
*
* @return \Doctrine\DBAL\Types\ConversionException
*/
public static function conversionFailed($value, $toType)
public static function conversionFailed($value, $toType, ?Throwable $previous = null)
{
$value = strlen($value) > 32 ? substr($value, 0, 20) . '...' : $value;
return new self('Could not convert database value "' . $value . '" to Doctrine Type ' . $toType);
return new self('Could not convert database value "' . $value . '" to Doctrine Type ' . $toType, 0, $previous);
}
/**
......@@ -64,8 +64,12 @@ class ConversionException extends DBALException
*
* @return \Doctrine\DBAL\Types\ConversionException
*/
public static function conversionFailedInvalidType($value, $toType, array $possibleTypes)
{
public static function conversionFailedInvalidType(
$value,
$toType,
array $possibleTypes,
?Throwable $previous = null
) {
$actualType = is_object($value) ? get_class($value) : gettype($value);
if (is_scalar($value)) {
......@@ -75,7 +79,7 @@ class ConversionException extends DBALException
$actualType,
$toType,
implode(', ', $possibleTypes)
));
), 0, $previous);
}
return new self(sprintf(
......@@ -83,7 +87,7 @@ class ConversionException extends DBALException
$actualType,
$toType,
implode(', ', $possibleTypes)
));
), 0, $previous);
}
public static function conversionFailedSerialization($value, $format, $error)
......
......@@ -17,7 +17,7 @@ class Version
/**
* Current Doctrine Version.
*/
public const VERSION = '2.10.1';
public const VERSION = '2.10.2-DEV';
/**
* Compares a Doctrine version with the current one.
......
......@@ -19,7 +19,6 @@ parameters:
- "~^Casting to bool something that's already bool.~"
- "~^Casting to int something that's already int.~"
- '~^Method Doctrine\\DBAL\\Driver\\IBMDB2\\DB2Connection::exec\(\) should return int but returns bool\.\z~'
- '~^Method Doctrine\\DBAL\\Query\\QueryBuilder::execute\(\) should return Doctrine\\DBAL\\Driver\\Statement\|int but returns Doctrine\\DBAL\\Driver\\ResultStatement\.\z~'
- '~^Property Doctrine\\DBAL\\Schema\\Table::\$_primaryKeyName \(string\) does not accept (default value of type )?false\.\z~'
- '~^Property Doctrine\\DBAL\\Schema\\Schema::\$_schemaConfig \(Doctrine\\DBAL\\Schema\\SchemaConfig\) does not accept default value of type false\.\z~'
- '~^Method Doctrine\\DBAL\\Schema\\ForeignKeyConstraint::onEvent\(\) should return string\|null but returns false\.\z~'
......
......@@ -335,6 +335,18 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertFalse($comparator->diffTable($offlineTable, $onlineTable));
}
public function testListTableDetailsWhenCurrentSchemaNameQuoted() : void
{
$this->connection->exec('CREATE SCHEMA "001_test"');
$this->connection->exec('SET search_path TO "001_test"');
try {
$this->testListQuotedTable();
} finally {
$this->connection->close();
}
}
public function testListTablesExcludesViews() : void
{
$this->createTestTable('list_tables_excludes_views');
......
......@@ -92,11 +92,22 @@ class QueryBuilderTest extends DbalTestCase
$qb->select('u.*', 'p.*')
->from('users', 'u')
->Join('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id'));
->join('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id'));
self::assertEquals('SELECT u.*, p.* FROM users u INNER JOIN phones p ON p.user_id = u.id', (string) $qb);
}
public function testSelectWithJoinNoCondition() : void
{
$qb = new QueryBuilder($this->conn);
$qb->select('u.*', 'p.*')
->from('users', 'u')
->join('u', 'phones', 'p');
self::assertEquals('SELECT u.*, p.* FROM users u INNER JOIN phones p', (string) $qb);
}
public function testSelectWithInnerJoin() : void
{
$qb = new QueryBuilder($this->conn);
......@@ -569,13 +580,27 @@ class QueryBuilderTest extends DbalTestCase
self::assertEquals($sql1, $qb->getSQL());
}
public function testSetMaxResults() : void
/**
* @dataProvider maxResultsProvider
*/
public function testSetMaxResults(?int $maxResults) : void
{
$qb = new QueryBuilder($this->conn);
$qb->setMaxResults(10);
$qb->setMaxResults($maxResults);
self::assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState());
self::assertEquals(10, $qb->getMaxResults());
self::assertEquals($maxResults, $qb->getMaxResults());
}
/**
* @return mixed[][]
*/
public static function maxResultsProvider() : iterable
{
return [
'non-null' => [10],
'null' => [null],
];
}
public function testSetFirstResult() : void
......
......@@ -4,6 +4,7 @@ namespace Doctrine\Tests\DBAL\Schema;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use PHPUnit\Framework\TestCase;
class ForeignKeyConstraintTest extends TestCase
......@@ -56,4 +57,30 @@ class ForeignKeyConstraintTest extends TestCase
[['FOO'], true],
];
}
/**
* @param string|Table $foreignTableName
*
* @group DBAL-1062
* @dataProvider getUnqualifiedForeignTableNameData
*/
public function testGetUnqualifiedForeignTableName($foreignTableName, string $expectedUnqualifiedTableName) : void
{
$foreignKey = new ForeignKeyConstraint(['foo', 'bar'], $foreignTableName, ['fk_foo', 'fk_bar']);
self::assertSame($expectedUnqualifiedTableName, $foreignKey->getUnqualifiedForeignTableName());
}
/**
* @return mixed[][]
*/
public static function getUnqualifiedForeignTableNameData() : iterable
{
return [
['schema.foreign_table', 'foreign_table'],
['foreign_table', 'foreign_table'],
[new Table('schema.foreign_table'), 'foreign_table'],
[new Table('foreign_table'), 'foreign_table'],
];
}
}
......@@ -3,13 +3,23 @@
namespace Doctrine\Tests\DBAL\Types;
use Doctrine\DBAL\Types\ConversionException;
use Exception;
use PHPUnit\Framework\TestCase;
use stdClass;
use Throwable;
use function tmpfile;
class ConversionExceptionTest extends TestCase
{
public function testConversionFailedPreviousException() : void
{
$previous = $this->createMock(Throwable::class);
$exception = ConversionException::conversionFailed('foo', 'foo', $previous);
self::assertInstanceOf(ConversionException::class, $exception);
self::assertSame($previous, $exception->getPrevious());
}
/**
* @param mixed $scalarValue
*
......@@ -44,9 +54,19 @@ class ConversionExceptionTest extends TestCase
);
}
public function testConversionFailedInvalidTypePreviousException() : void
{
$previous = $this->createMock(Throwable::class);
$exception = ConversionException::conversionFailedInvalidType('foo', 'foo', ['bar', 'baz'], $previous);
self::assertInstanceOf(ConversionException::class, $exception);
self::assertSame($previous, $exception->getPrevious());
}
public function testConversionFailedFormatPreservesPreviousException() : void
{
$previous = new Exception();
$previous = $this->createMock(Throwable::class);
$exception = ConversionException::conversionFailedFormat('foo', 'bar', 'baz', $previous);
......
CREATE SCHEMA doctrine_tests;
CREATE SCHEMA test_create_database;
CREATE SCHEMA test_drop_database;
GRANT ALL PRIVILEGES ON doctrine_tests.* to travis@'%';
GRANT ALL PRIVILEGES ON test_create_database.* to travis@'%';
GRANT ALL PRIVILEGES ON test_drop_database.* to travis@'%';
#!/usr/bin/env bash
set -ex
echo "Starting RDBMS…">&2
if [[ "$IMAGE" == "mysql:8.0" ]]
then
CMD_OPTIONS="--default-authentication-plugin=mysql_native_password"
else
CMD_OPTIONS=""
fi
docker run \
--health-cmd='mysqladmin ping --silent' \
--detach \
--env MYSQL_ALLOW_EMPTY_PASSWORD=yes \
--env MYSQL_DATABASE=doctrine_tests \
--publish 33306:3306 \
--name rdbms \
"$IMAGE" $CMD_OPTIONS
while true; do
healthStatus=$(docker inspect --format "{{json .State.Health.Status }}" rdbms)
case $healthStatus in
'"starting"')
echo "Waiting for RDBMS to become ready…">&2
sleep 1
;;
'"healthy"')
echo "Container is healthy">&2
break
;;
'"unhealthy"')
echo "Container is unhealthy">&2
exit 1
;;
*)
echo "Unexpected health status $healthStatus">&2
;;
esac
done
#!/usr/bin/env bash
set -ex
echo "Starting MySQL 5.7..."
sudo docker run \
-d \
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes \
-e MYSQL_DATABASE=doctrine_tests \
-p 33306:3306 \
--name mysql57 \
mysql:5.7
sudo docker exec -i mysql57 bash <<< 'until echo \\q | mysql doctrine_tests > /dev/null 2>&1 ; do sleep 1; done'
#!/usr/bin/env bash
set -ex
echo "Starting MySQL 8.0..."
sudo docker pull mysql:8.0
sudo docker run \
-d \
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes \
-e MYSQL_DATABASE=doctrine_tests \
-p 33306:3306 \
--name mysql80 \
mysql:8.0 \
--default-authentication-plugin=mysql_native_password
sudo docker exec -i mysql80 bash <<< 'until echo \\q | mysql doctrine_tests > /dev/null 2>&1 ; do sleep 1; done'
......@@ -5,6 +5,6 @@ set -ex
echo Installing driver dependencies
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/14.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql.list
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql.list
sudo apt-get update
ACCEPT_EULA=Y sudo apt-get install -qy msodbcsql17 unixodbc unixodbc-dev libssl1.0.0
......@@ -11,17 +11,17 @@
<ini name="error_reporting" value="-1" />
<var name="db_type" value="pdo_mysql"/>
<var name="db_host" value="localhost" />
<var name="db_username" value="travis" />
<var name="db_host" value="127.0.0.1" />
<var name="db_username" value="root" />
<var name="db_password" value="" />
<var name="db_name" value="doctrine_tests" />
<var name="db_port" value="3306"/>
<var name="db_port" value="33306"/>
<var name="tmpdb_type" value="pdo_mysql"/>
<var name="tmpdb_host" value="localhost" />
<var name="tmpdb_username" value="travis" />
<var name="tmpdb_host" value="127.0.0.1" />
<var name="tmpdb_username" value="root" />
<var name="tmpdb_password" value="" />
<var name="tmpdb_port" value="3306"/>
<var name="tmpdb_port" value="33306"/>
</php>
<testsuites>
......
......@@ -11,17 +11,17 @@
<ini name="error_reporting" value="-1" />
<var name="db_type" value="mysqli"/>
<var name="db_host" value="localhost" />
<var name="db_username" value="travis" />
<var name="db_host" value="127.0.0.1" />
<var name="db_username" value="root" />
<var name="db_password" value="" />
<var name="db_name" value="doctrine_tests" />
<var name="db_port" value="3306"/>
<var name="db_port" value="33306"/>
<var name="tmpdb_type" value="mysqli"/>
<var name="tmpdb_host" value="localhost" />
<var name="tmpdb_username" value="travis" />
<var name="tmpdb_host" value="127.0.0.1" />
<var name="tmpdb_username" value="root" />
<var name="tmpdb_password" value="" />
<var name="tmpdb_port" value="3306"/>
<var name="tmpdb_port" value="33306"/>
</php>
<testsuites>
......
<?xml version="1.0" encoding="utf-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
bootstrap="../../vendor/autoload.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
<php>
<ini name="error_reporting" value="-1" />
<var name="db_type" value="mysqli"/>
<var name="db_host" value="localhost" />
<var name="db_username" value="travis" />
<var name="db_password" value="" />
<var name="db_name" value="doctrine_tests" />
<var name="db_port" value="3306"/>
<var name="tmpdb_type" value="mysqli"/>
<var name="tmpdb_host" value="localhost" />
<var name="tmpdb_username" value="travis" />
<var name="tmpdb_password" value="" />
<var name="tmpdb_port" value="3306"/>
</php>
<testsuites>
<testsuite name="Doctrine DBAL Test Suite">
<directory>../Doctrine/Tests/DBAL</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">../../lib/Doctrine</directory>
</whitelist>
</filter>
<groups>
<exclude>
<group>performance</group>
<group>locking_functional</group>
</exclude>
</groups>
</phpunit>
<?xml version="1.0" encoding="utf-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
<php>
<ini name="error_reporting" value="-1" />
<var name="db_type" value="pdo_mysql"/>
<var name="db_host" value="localhost" />
<var name="db_username" value="travis" />
<var name="db_password" value="" />
<var name="db_name" value="doctrine_tests" />
<var name="db_port" value="3306"/>
<var name="tmpdb_type" value="pdo_mysql"/>
<var name="tmpdb_host" value="localhost" />
<var name="tmpdb_username" value="travis" />
<var name="tmpdb_password" value="" />
<var name="tmpdb_port" value="3306"/>
</php>
<testsuites>
<testsuite name="Doctrine DBAL Test Suite">
<directory>../Doctrine/Tests/DBAL</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">../../lib/Doctrine</directory>
</whitelist>
</filter>
<groups>
<exclude>
<group>performance</group>
<group>locking_functional</group>
</exclude>
</groups>
</phpunit>
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