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: ...@@ -21,7 +21,7 @@ before_commands:
tools: tools:
external_code_coverage: external_code_coverage:
timeout: 3600 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: filter:
excluded_paths: excluded_paths:
......
language: php language: php
sudo: false dist: xenial
dist: trusty
cache: cache:
directories: directories:
...@@ -15,7 +14,11 @@ before_install: ...@@ -15,7 +14,11 @@ before_install:
fi fi
before_script: 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: install:
- travis_retry composer -n install --prefer-dist - travis_retry composer -n install --prefer-dist
...@@ -54,36 +57,20 @@ jobs: ...@@ -54,36 +57,20 @@ jobs:
- stage: Test - stage: Test
php: 7.2 php: 7.2
env: DB=mysql.docker MYSQL_VERSION=8.0 env: DB=mysql.docker IMAGE=mysql:8.0
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
- stage: Test - stage: Test
php: 7.2 php: 7.2
env: DB=mysqli.docker MYSQL_VERSION=8.0 env: DB=mysqli.docker IMAGE=mysql:8.0
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
- stage: Test - stage: Test
php: 7.2 php: 7.2
env: DB=mariadb MARIADB_VERSION=10.3 env: DB=mariadb.docker IMAGE=mariadb:10.3
addons:
mariadb: 10.3
- stage: Test - stage: Test
php: 7.2 php: 7.2
env: DB=mariadb.mysqli MARIADB_VERSION=10.3 env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.3
addons:
mariadb: 10.3
- stage: Test - stage: Test
php: 7.2 php: 7.2
env: DB=pgsql POSTGRESQL_VERSION=11.0 env: DB=pgsql POSTGRESQL_VERSION=11.0
sudo: required sudo: required
services:
- docker
before_script: before_script:
- bash ./tests/travis/install-postgres-11.sh - bash ./tests/travis/install-postgres-11.sh
- stage: Test - stage: Test
...@@ -93,8 +80,6 @@ jobs: ...@@ -93,8 +80,6 @@ jobs:
php: 7.2 php: 7.2
env: DB=sqlsrv env: DB=sqlsrv
sudo: required sudo: required
services:
- docker
before_script: before_script:
- bash ./tests/travis/install-sqlsrv-dependencies.sh - bash ./tests/travis/install-sqlsrv-dependencies.sh
- bash ./tests/travis/install-mssql-sqlsrv.sh - bash ./tests/travis/install-mssql-sqlsrv.sh
...@@ -103,87 +88,48 @@ jobs: ...@@ -103,87 +88,48 @@ jobs:
php: 7.2 php: 7.2
env: DB=pdo_sqlsrv env: DB=pdo_sqlsrv
sudo: required sudo: required
services:
- docker
before_script: before_script:
- bash ./tests/travis/install-sqlsrv-dependencies.sh - bash ./tests/travis/install-sqlsrv-dependencies.sh
- bash ./tests/travis/install-mssql-pdo_sqlsrv.sh - bash ./tests/travis/install-mssql-pdo_sqlsrv.sh
- bash ./tests/travis/install-mssql.sh - bash ./tests/travis/install-mssql.sh
- stage: Test - stage: Test
php: 7.3 php: 7.3
env: DB=mysql COVERAGE=yes env: DB=mysql.docker IMAGE=mysql:5.7 COVERAGE=yes
- stage: Test - stage: Test
php: 7.3 php: 7.3
env: DB=mysql.docker MYSQL_VERSION=5.7 COVERAGE=yes env: DB=mysql.docker IMAGE=mysql:8.0 COVERAGE=yes
sudo: required
before_script:
- bash ./tests/travis/install-mysql-5.7.sh
- stage: Test - stage: Test
php: 7.3 php: 7.3
env: DB=mysql.docker MYSQL_VERSION=8.0 COVERAGE=yes env: DB=mysqli.docker IMAGE=mysql:5.7 COVERAGE=yes
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
- stage: Test - stage: Test
php: 7.3 php: 7.3
env: DB=mysqli COVERAGE=yes env: DB=mysqli.docker IMAGE=mysql:8.0 COVERAGE=yes
- stage: Test - stage: Test
php: 7.3 php: 7.3
env: DB=mysqli.docker MYSQL_VERSION=5.7 COVERAGE=yes env: DB=mariadb.docker IMAGE=mariadb:10.0 COVERAGE=yes
sudo: required
before_script:
- bash ./tests/travis/install-mysql-5.7.sh
- stage: Test - stage: Test
php: 7.3 php: 7.3
env: DB=mysqli.docker MYSQL_VERSION=8.0 COVERAGE=yes env: DB=mariadb.docker IMAGE=mariadb:10.1 COVERAGE=yes
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
- stage: Test - stage: Test
php: 7.3 php: 7.3
env: DB=mariadb MARIADB_VERSION=10.0 COVERAGE=yes env: DB=mariadb.docker IMAGE=mariadb:10.2 COVERAGE=yes
addons:
mariadb: 10.0
- stage: Test - stage: Test
php: 7.3 php: 7.3
env: DB=mariadb MARIADB_VERSION=10.1 COVERAGE=yes env: DB=mariadb.docker IMAGE=mariadb:10.3 COVERAGE=yes
addons:
mariadb: 10.1
- stage: Test - stage: Test
php: 7.3 php: 7.3
env: DB=mariadb MARIADB_VERSION=10.2 COVERAGE=yes env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.0 COVERAGE=yes
addons:
mariadb: 10.2
- stage: Test - stage: Test
php: 7.3 php: 7.3
env: DB=mariadb MARIADB_VERSION=10.3 COVERAGE=yes env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.1 COVERAGE=yes
addons:
mariadb: 10.3
- stage: Test - stage: Test
php: 7.3 php: 7.3
env: DB=mariadb.mysqli MARIADB_VERSION=10.0 COVERAGE=yes env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.2 COVERAGE=yes
addons:
mariadb: 10.0
- stage: Test - stage: Test
php: 7.3 php: 7.3
env: DB=mariadb.mysqli MARIADB_VERSION=10.1 COVERAGE=yes env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.3 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
- stage: Test - stage: Test
dist: trusty
php: 7.3 php: 7.3
env: DB=pgsql POSTGRESQL_VERSION=9.2 COVERAGE=yes env: DB=pgsql POSTGRESQL_VERSION=9.2 COVERAGE=yes
services: services:
...@@ -191,6 +137,7 @@ jobs: ...@@ -191,6 +137,7 @@ jobs:
addons: addons:
postgresql: "9.2" postgresql: "9.2"
- stage: Test - stage: Test
dist: trusty
php: 7.3 php: 7.3
env: DB=pgsql POSTGRESQL_VERSION=9.3 COVERAGE=yes env: DB=pgsql POSTGRESQL_VERSION=9.3 COVERAGE=yes
services: services:
...@@ -200,48 +147,36 @@ jobs: ...@@ -200,48 +147,36 @@ jobs:
- stage: Test - stage: Test
php: 7.3 php: 7.3
env: DB=pgsql POSTGRESQL_VERSION=9.4 COVERAGE=yes env: DB=pgsql POSTGRESQL_VERSION=9.4 COVERAGE=yes
services:
- postgresql
addons: addons:
postgresql: "9.4" postgresql: "9.4"
- stage: Test - stage: Test
php: 7.3 php: 7.3
env: DB=pgsql POSTGRESQL_VERSION=9.5 COVERAGE=yes env: DB=pgsql POSTGRESQL_VERSION=9.5 COVERAGE=yes
services:
- postgresql
addons: addons:
postgresql: "9.5" postgresql: "9.5"
- stage: Test - stage: Test
php: 7.3 php: 7.3
env: DB=pgsql POSTGRESQL_VERSION=9.6 COVERAGE=yes env: DB=pgsql POSTGRESQL_VERSION=9.6 COVERAGE=yes
services:
- postgresql
addons: addons:
postgresql: "9.6" postgresql: "9.6"
- stage: Test - stage: Test
php: 7.3 php: 7.3
env: DB=pgsql POSTGRESQL_VERSION=10.0 COVERAGE=yes env: DB=pgsql POSTGRESQL_VERSION=10.0 COVERAGE=yes
sudo: required sudo: required
services:
- postgresql
addons: addons:
postgresql: "9.6" postgresql: "10"
before_script: before_script:
- bash ./tests/travis/install-postgres-10.sh - bash ./tests/travis/install-postgres-10.sh
- stage: Test - stage: Test
php: 7.3 php: 7.3
env: DB=pgsql POSTGRESQL_VERSION=11.0 COVERAGE=yes env: DB=pgsql POSTGRESQL_VERSION=11.0 COVERAGE=yes
sudo: required sudo: required
services:
- docker
before_script: before_script:
- bash ./tests/travis/install-postgres-11.sh - bash ./tests/travis/install-postgres-11.sh
- stage: Test - stage: Test
php: 7.3 php: 7.3
env: DB=sqlsrv COVERAGE=yes env: DB=sqlsrv COVERAGE=yes
sudo: required sudo: required
services:
- docker
before_script: before_script:
- bash ./tests/travis/install-sqlsrv-dependencies.sh - bash ./tests/travis/install-sqlsrv-dependencies.sh
- bash ./tests/travis/install-mssql-sqlsrv.sh - bash ./tests/travis/install-mssql-sqlsrv.sh
...@@ -250,8 +185,6 @@ jobs: ...@@ -250,8 +185,6 @@ jobs:
php: 7.3 php: 7.3
env: DB=pdo_sqlsrv COVERAGE=yes env: DB=pdo_sqlsrv COVERAGE=yes
sudo: required sudo: required
services:
- docker
before_script: before_script:
- bash ./tests/travis/install-sqlsrv-dependencies.sh - bash ./tests/travis/install-sqlsrv-dependencies.sh
- bash ./tests/travis/install-mssql-pdo_sqlsrv.sh - bash ./tests/travis/install-mssql-pdo_sqlsrv.sh
...@@ -260,8 +193,6 @@ jobs: ...@@ -260,8 +193,6 @@ jobs:
php: 7.3 php: 7.3
env: DB=ibm_db2 COVERAGE=yes env: DB=ibm_db2 COVERAGE=yes
sudo: required sudo: required
services:
- docker
before_script: before_script:
- bash ./tests/travis/install-db2.sh - bash ./tests/travis/install-db2.sh
- bash ./tests/travis/install-db2-ibm_db2.sh - bash ./tests/travis/install-db2-ibm_db2.sh
...@@ -271,58 +202,38 @@ jobs: ...@@ -271,58 +202,38 @@ jobs:
install: install:
- travis_retry composer update --prefer-dist --prefer-lowest - travis_retry composer update --prefer-dist --prefer-lowest
- stage: Test - stage: Test
php: 7.4snapshot php: 7.4
env: DB=mysql.docker MYSQL_VERSION=8.0 env: DB=mysql.docker IMAGE=mysql:8.0
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
- stage: Test - stage: Test
php: 7.4snapshot php: 7.4
env: DB=mysqli.docker MYSQL_VERSION=8.0 env: DB=mysqli.docker IMAGE=mysql:8.0
sudo: required
services:
- docker
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
- stage: Test - stage: Test
php: 7.4snapshot php: 7.4
env: DB=mariadb MARIADB_VERSION=10.3 env: DB=mariadb.docker IMAGE=mariadb:10.3
addons:
mariadb: 10.3
- stage: Test - stage: Test
php: 7.4snapshot php: 7.4
env: DB=mariadb.mysqli MARIADB_VERSION=10.3 env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.3
addons:
mariadb: 10.3
- stage: Test - stage: Test
php: 7.4snapshot php: 7.4
env: DB=pgsql POSTGRESQL_VERSION=11.0 env: DB=pgsql POSTGRESQL_VERSION=11.0
sudo: required sudo: required
services:
- docker
before_script: before_script:
- bash ./tests/travis/install-postgres-11.sh - bash ./tests/travis/install-postgres-11.sh
- stage: Test - stage: Test
php: 7.4snapshot php: 7.4
env: DB=sqlite env: DB=sqlite
- stage: Test - stage: Test
php: 7.4snapshot php: 7.4
env: DB=sqlsrv env: DB=sqlsrv
sudo: required sudo: required
services:
- docker
before_script: before_script:
- bash ./tests/travis/install-sqlsrv-dependencies.sh - bash ./tests/travis/install-sqlsrv-dependencies.sh
- bash ./tests/travis/install-mssql-sqlsrv.sh - bash ./tests/travis/install-mssql-sqlsrv.sh
- bash ./tests/travis/install-mssql.sh - bash ./tests/travis/install-mssql.sh
- stage: Test - stage: Test
php: 7.4snapshot php: 7.4
env: DB=pdo_sqlsrv env: DB=pdo_sqlsrv
sudo: required sudo: required
services:
- docker
before_script: before_script:
- bash ./tests/travis/install-sqlsrv-dependencies.sh - bash ./tests/travis/install-sqlsrv-dependencies.sh
- bash ./tests/travis/install-mssql-pdo_sqlsrv.sh - bash ./tests/travis/install-mssql-pdo_sqlsrv.sh
......
# Doctrine DBAL # Doctrine DBAL
| [Master][Master] | [2.9][2.9] | [Develop][develop] | | [Master][Master] | [2.10][2.10] |
|:----------------:|:----------:|:------------------:| |:----------------:|:----------:|
| [![Build status][Master image]][Master] | [![Build status][2.9 image]][2.9] | [![Build status][develop image]][develop] | | [![Build status][Master image]][Master] | [![Build status][2.10 image]][2.10] |
| [![Build Status][ContinuousPHP image]][ContinuousPHP] | [![Build Status][ContinuousPHP 2.9 image]][ContinuousPHP] | [![Build Status][ContinuousPHP develop image]][ContinuousPHP] | | [![Build Status][ContinuousPHP image]][ContinuousPHP] | [![Build Status][ContinuousPHP 2.10 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 Coverage][Coverage image]][Scrutinizer Master] | [![Code Coverage][Coverage 2.10 image]][Scrutinizer 2.10] |
| [![Code Quality][Quality image]][Scrutinizer Master] | [![Code Quality][Quality 2.9 image]][Scrutinizer 2.9] | [![Code Quality][Quality develop image]][Scrutinizer develop] | | [![Code Quality][Quality image]][Scrutinizer Master] | [![Code Quality][Quality 2.10 image]][Scrutinizer 2.10] |
| [![AppVeyor][AppVeyor master image]][AppVeyor master] | [![AppVeyor][AppVeyor 2.9 image]][AppVeyor 2.9] | [![AppVeyor][AppVeyor develop image]][AppVeyor develop] | | [![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. 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 ...@@ -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 [AppVeyor master image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/master?svg=true
[ContinuousPHP]: https://continuousphp.com/git-hub/doctrine/dbal [ContinuousPHP]: https://continuousphp.com/git-hub/doctrine/dbal
[2.9 image]: https://img.shields.io/travis/doctrine/dbal/2.9.svg?style=flat-square [2.10 image]: https://img.shields.io/travis/doctrine/dbal/2.10.x.svg?style=flat-square
[Coverage 2.9 image]: https://img.shields.io/scrutinizer/coverage/g/doctrine/dbal/2.9.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.9 image]: https://img.shields.io/scrutinizer/g/doctrine/dbal/2.9.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.9 image]: https://img.shields.io/continuousphp/git-hub/doctrine/dbal/2.9.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.9]: https://github.com/doctrine/dbal/tree/2.9 [2.10]: https://github.com/doctrine/dbal/tree/2.10.x
[Scrutinizer 2.9]: https://scrutinizer-ci.com/g/doctrine/dbal/?branch=2.9 [Scrutinizer 2.10]: https://scrutinizer-ci.com/g/doctrine/dbal/?branch=2.10.x
[AppVeyor 2.9]: https://ci.appveyor.com/project/doctrine/dbal/branch/2.9 [AppVeyor 2.10]: https://ci.appveyor.com/project/doctrine/dbal/branch/2.10.x
[AppVeyor 2.9 image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/2.9?svg=true [AppVeyor 2.10 image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/2.10.x?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
...@@ -160,7 +160,7 @@ following code in Doctrine: ...@@ -160,7 +160,7 @@ following code in Doctrine:
use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Id\TableGenerator; use Doctrine\DBAL\Id\TableGenerator;
$conn = DriverManager::getConnection(/**..**); // connection 1 $conn = DriverManager::getConnection(/**..**/); // connection 1
// creating the TableGenerator automatically opens a second connection. // creating the TableGenerator automatically opens a second connection.
$tableGenerator = new TableGenerator($conn, "sequences_tbl_name"); $tableGenerator = new TableGenerator($conn, "sequences_tbl_name");
......
...@@ -88,20 +88,7 @@ final class DriverManager ...@@ -88,20 +88,7 @@ final class DriverManager
* *
* $params must contain at least one of the following. * $params must contain at least one of the following.
* *
* Either 'driver' with one of the following values: * Either 'driver' with one of the array keys of {@link $_driverMap},
*
* pdo_mysql
* pdo_sqlite
* pdo_pgsql
* pdo_oci (unstable)
* pdo_sqlsrv
* pdo_sqlsrv
* mysqli
* sqlanywhere
* sqlsrv
* ibm_db2 (unstable)
* drizzle_pdo_mysql
*
* OR 'driverClass' that contains the full class name (with namespace) of the * OR 'driverClass' that contains the full class name (with namespace) of the
* driver class to instantiate. * driver class to instantiate.
* *
......
...@@ -12,7 +12,7 @@ class DebugStack implements SQLLogger ...@@ -12,7 +12,7 @@ class DebugStack implements SQLLogger
/** /**
* Executed SQL queries. * Executed SQL queries.
* *
* @var mixed[][] * @var array<int, array<string, mixed>>
*/ */
public $queries = []; public $queries = [];
......
...@@ -367,7 +367,7 @@ SQL ...@@ -367,7 +367,7 @@ SQL
[$schema, $table] = explode('.', $table); [$schema, $table] = explode('.', $table);
$schema = $this->quoteStringLiteral($schema); $schema = $this->quoteStringLiteral($schema);
} else { } 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); $table = new Identifier($table);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace Doctrine\DBAL\Query; namespace Doctrine\DBAL\Query;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Query\Expression\CompositeExpression; use Doctrine\DBAL\Query\Expression\CompositeExpression;
use Doctrine\DBAL\Query\Expression\ExpressionBuilder; use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
...@@ -118,9 +118,9 @@ class QueryBuilder ...@@ -118,9 +118,9 @@ class QueryBuilder
private $firstResult = null; 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; private $maxResults = null;
...@@ -198,7 +198,7 @@ class QueryBuilder ...@@ -198,7 +198,7 @@ class QueryBuilder
* Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate} * Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate}
* for insert, update and delete statements. * for insert, update and delete statements.
* *
* @return Statement|int * @return ResultStatement|int
*/ */
public function execute() public function execute()
{ {
...@@ -367,7 +367,6 @@ class QueryBuilder ...@@ -367,7 +367,6 @@ class QueryBuilder
/** /**
* Gets the position of the first result the query object was set to retrieve (the "offset"). * 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. * @return int The position of the first result.
*/ */
...@@ -379,7 +378,7 @@ class QueryBuilder ...@@ -379,7 +378,7 @@ class QueryBuilder
/** /**
* Sets the maximum number of results to retrieve (the "limit"). * 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. * @return $this This QueryBuilder instance.
*/ */
...@@ -393,7 +392,7 @@ class QueryBuilder ...@@ -393,7 +392,7 @@ class QueryBuilder
/** /**
* Gets the maximum number of results the query object was set to retrieve (the "limit"). * 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. * @return int The maximum number of results.
*/ */
...@@ -1339,9 +1338,11 @@ class QueryBuilder ...@@ -1339,9 +1338,11 @@ class QueryBuilder
if (array_key_exists($join['joinAlias'], $knownAliases)) { if (array_key_exists($join['joinAlias'], $knownAliases)) {
throw QueryException::nonUniqueAlias($join['joinAlias'], array_keys($knownAliases)); throw QueryException::nonUniqueAlias($join['joinAlias'], array_keys($knownAliases));
} }
$sql .= ' ' . strtoupper($join['joinType']) $sql .= ' ' . strtoupper($join['joinType'])
. ' JOIN ' . $join['joinTable'] . ' ' . $join['joinAlias'] . ' JOIN ' . $join['joinTable'] . ' ' . $join['joinAlias'];
. ' ON ' . ((string) $join['joinCondition']); if ($join['joinCondition'] !== null) {
$sql .= ' ON ' . $join['joinCondition'];
}
$knownAliases[$join['joinAlias']] = true; $knownAliases[$join['joinAlias']] = true;
} }
......
...@@ -4,7 +4,9 @@ namespace Doctrine\DBAL; ...@@ -4,7 +4,9 @@ namespace Doctrine\DBAL;
use const PREG_OFFSET_CAPTURE; use const PREG_OFFSET_CAPTURE;
use function array_fill; use function array_fill;
use function array_fill_keys;
use function array_key_exists; use function array_key_exists;
use function array_keys;
use function array_merge; use function array_merge;
use function array_slice; use function array_slice;
use function array_values; use function array_values;
...@@ -31,9 +33,9 @@ class SQLParserUtils ...@@ -31,9 +33,9 @@ class SQLParserUtils
public const POSITIONAL_TOKEN = '\?'; public const POSITIONAL_TOKEN = '\?';
public const NAMED_TOKEN = '(?<!:):[a-zA-Z_][a-zA-Z0-9_]*'; public const NAMED_TOKEN = '(?<!:):[a-zA-Z_][a-zA-Z0-9_]*';
// Quote characters within string literals can be preceded by a backslash. // Quote characters within string literals can be preceded by a backslash.
public const ESCAPED_SINGLE_QUOTED_TEXT = "(?:'(?:\\\\\\\\)+'|'(?:[^'\\\\]|\\\\'?|'')*')"; public const ESCAPED_SINGLE_QUOTED_TEXT = "(?:'(?:\\\\)+'|'(?:[^'\\\\]|\\\\'?|'')*')";
public const ESCAPED_DOUBLE_QUOTED_TEXT = '(?:"(?:\\\\\\\\)+"|"(?:[^"\\\\]|\\\\"?)*")'; public const ESCAPED_DOUBLE_QUOTED_TEXT = '(?:"(?:\\\\)+"|"(?:[^"\\\\]|\\\\"?)*")';
public const ESCAPED_BACKTICK_QUOTED_TEXT = '(?:`(?:\\\\\\\\)+`|`(?:[^`\\\\]|\\\\`?)*`)'; public const ESCAPED_BACKTICK_QUOTED_TEXT = '(?:`(?:\\\\)+`|`(?:[^`\\\\]|\\\\`?)*`)';
/**#@-*/ /**#@-*/
private const ESCAPED_BRACKET_QUOTED_TEXT = '(?<!\b(?i:ARRAY))\[(?:[^\]])*\]'; private const ESCAPED_BRACKET_QUOTED_TEXT = '(?<!\b(?i:ARRAY))\[(?:[^\]])*\]';
...@@ -131,6 +133,10 @@ class SQLParserUtils ...@@ -131,6 +133,10 @@ class SQLParserUtils
$bindIndex = -1; $bindIndex = -1;
if ($isPositional) { 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($params);
ksort($types); ksort($types);
} }
......
...@@ -233,7 +233,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -233,7 +233,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
$position = strrpos($name, '.'); $position = strrpos($name, '.');
if ($position !== false) { if ($position !== false) {
$name = substr($name, $position); $name = substr($name, $position + 1);
} }
return strtolower($name); return strtolower($name);
......
...@@ -26,11 +26,11 @@ class ConversionException extends DBALException ...@@ -26,11 +26,11 @@ class ConversionException extends DBALException
* *
* @return \Doctrine\DBAL\Types\ConversionException * @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; $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 ...@@ -64,8 +64,12 @@ class ConversionException extends DBALException
* *
* @return \Doctrine\DBAL\Types\ConversionException * @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); $actualType = is_object($value) ? get_class($value) : gettype($value);
if (is_scalar($value)) { if (is_scalar($value)) {
...@@ -75,7 +79,7 @@ class ConversionException extends DBALException ...@@ -75,7 +79,7 @@ class ConversionException extends DBALException
$actualType, $actualType,
$toType, $toType,
implode(', ', $possibleTypes) implode(', ', $possibleTypes)
)); ), 0, $previous);
} }
return new self(sprintf( return new self(sprintf(
...@@ -83,7 +87,7 @@ class ConversionException extends DBALException ...@@ -83,7 +87,7 @@ class ConversionException extends DBALException
$actualType, $actualType,
$toType, $toType,
implode(', ', $possibleTypes) implode(', ', $possibleTypes)
)); ), 0, $previous);
} }
public static function conversionFailedSerialization($value, $format, $error) public static function conversionFailedSerialization($value, $format, $error)
......
...@@ -17,7 +17,7 @@ class Version ...@@ -17,7 +17,7 @@ class Version
/** /**
* Current Doctrine 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. * Compares a Doctrine version with the current one.
......
...@@ -19,7 +19,6 @@ parameters: ...@@ -19,7 +19,6 @@ parameters:
- "~^Casting to bool something that's already bool.~" - "~^Casting to bool something that's already bool.~"
- "~^Casting to int something that's already int.~" - "~^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\\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\\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~' - '~^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~' - '~^Method Doctrine\\DBAL\\Schema\\ForeignKeyConstraint::onEvent\(\) should return string\|null but returns false\.\z~'
......
...@@ -335,6 +335,18 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -335,6 +335,18 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertFalse($comparator->diffTable($offlineTable, $onlineTable)); 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 public function testListTablesExcludesViews() : void
{ {
$this->createTestTable('list_tables_excludes_views'); $this->createTestTable('list_tables_excludes_views');
......
...@@ -92,11 +92,22 @@ class QueryBuilderTest extends DbalTestCase ...@@ -92,11 +92,22 @@ class QueryBuilderTest extends DbalTestCase
$qb->select('u.*', 'p.*') $qb->select('u.*', 'p.*')
->from('users', 'u') ->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); 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 public function testSelectWithInnerJoin() : void
{ {
$qb = new QueryBuilder($this->conn); $qb = new QueryBuilder($this->conn);
...@@ -569,13 +580,27 @@ class QueryBuilderTest extends DbalTestCase ...@@ -569,13 +580,27 @@ class QueryBuilderTest extends DbalTestCase
self::assertEquals($sql1, $qb->getSQL()); self::assertEquals($sql1, $qb->getSQL());
} }
public function testSetMaxResults() : void /**
* @dataProvider maxResultsProvider
*/
public function testSetMaxResults(?int $maxResults) : void
{ {
$qb = new QueryBuilder($this->conn); $qb = new QueryBuilder($this->conn);
$qb->setMaxResults(10); $qb->setMaxResults($maxResults);
self::assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState()); 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 public function testSetFirstResult() : void
......
...@@ -89,7 +89,7 @@ SQLDATA ...@@ -89,7 +89,7 @@ SQLDATA
['SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE "\\\\") AND (data.description LIKE :condition_1 ESCAPE \'\\\\\') ORDER BY id ASC', false, [121 => 'condition_0', 174 => 'condition_1']], ['SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE "\\\\") AND (data.description LIKE :condition_1 ESCAPE \'\\\\\') ORDER BY id ASC', false, [121 => 'condition_0', 174 => 'condition_1']],
['SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE `\\\\`) AND (data.description LIKE :condition_1 ESCAPE `\\\\`) ORDER BY id ASC', false, [121 => 'condition_0', 174 => 'condition_1']], ['SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE `\\\\`) AND (data.description LIKE :condition_1 ESCAPE `\\\\`) ORDER BY id ASC', false, [121 => 'condition_0', 174 => 'condition_1']],
['SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE \'\\\\\') AND (data.description LIKE :condition_1 ESCAPE `\\\\`) ORDER BY id ASC', false, [121 => 'condition_0', 174 => 'condition_1']], ['SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE \'\\\\\') AND (data.description LIKE :condition_1 ESCAPE `\\\\`) ORDER BY id ASC', false, [121 => 'condition_0', 174 => 'condition_1']],
["SELECT * FROM Foo WHERE (foo.bar LIKE :condition_0 ESCAPE '\') AND (foo.baz = :condition_1) AND (foo.bak LIKE :condition_2 ESCAPE '\')", false, [38 => 'condition_0', 78 => 'condition_1', 110 => 'condition_2']],
]; ];
} }
...@@ -110,8 +110,7 @@ SQLDATA ...@@ -110,8 +110,7 @@ SQLDATA
public static function dataExpandListParameters() : iterable public static function dataExpandListParameters() : iterable
{ {
return [ return [
// Positional: Very simple with one needle 'Positional: Very simple with one needle' => [
[
'SELECT * FROM Foo WHERE foo IN (?)', 'SELECT * FROM Foo WHERE foo IN (?)',
[[1, 2, 3]], [[1, 2, 3]],
[Connection::PARAM_INT_ARRAY], [Connection::PARAM_INT_ARRAY],
...@@ -119,8 +118,7 @@ SQLDATA ...@@ -119,8 +118,7 @@ SQLDATA
[1, 2, 3], [1, 2, 3],
[ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER], [ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER],
], ],
// Positional: One non-list before d one after list-needle 'Positional: One non-list before d one after list-needle' => [
[
'SELECT * FROM Foo WHERE foo = ? AND bar IN (?)', 'SELECT * FROM Foo WHERE foo = ? AND bar IN (?)',
['string', [1, 2, 3]], ['string', [1, 2, 3]],
[ParameterType::STRING, Connection::PARAM_INT_ARRAY], [ParameterType::STRING, Connection::PARAM_INT_ARRAY],
...@@ -128,8 +126,7 @@ SQLDATA ...@@ -128,8 +126,7 @@ SQLDATA
['string', 1, 2, 3], ['string', 1, 2, 3],
[ParameterType::STRING, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER], [ParameterType::STRING, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER],
], ],
// Positional: One non-list after list-needle 'Positional: One non-list after list-needle' => [
[
'SELECT * FROM Foo WHERE bar IN (?) AND baz = ?', 'SELECT * FROM Foo WHERE bar IN (?) AND baz = ?',
[[1, 2, 3], 'foo'], [[1, 2, 3], 'foo'],
[Connection::PARAM_INT_ARRAY, ParameterType::STRING], [Connection::PARAM_INT_ARRAY, ParameterType::STRING],
...@@ -137,8 +134,7 @@ SQLDATA ...@@ -137,8 +134,7 @@ SQLDATA
[1, 2, 3, 'foo'], [1, 2, 3, 'foo'],
[ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING], [ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING],
], ],
// Positional: One non-list before and one after list-needle 'Positional: One non-list before and one after list-needle' => [
[
'SELECT * FROM Foo WHERE foo = ? AND bar IN (?) AND baz = ?', 'SELECT * FROM Foo WHERE foo = ? AND bar IN (?) AND baz = ?',
[1, [1, 2, 3], 4], [1, [1, 2, 3], 4],
[ParameterType::INTEGER, Connection::PARAM_INT_ARRAY, ParameterType::INTEGER], [ParameterType::INTEGER, Connection::PARAM_INT_ARRAY, ParameterType::INTEGER],
...@@ -152,8 +148,7 @@ SQLDATA ...@@ -152,8 +148,7 @@ SQLDATA
ParameterType::INTEGER, ParameterType::INTEGER,
], ],
], ],
// Positional: Two lists 'Positional: Two lists' => [
[
'SELECT * FROM Foo WHERE foo IN (?, ?)', 'SELECT * FROM Foo WHERE foo IN (?, ?)',
[[1, 2, 3], [4, 5]], [[1, 2, 3], [4, 5]],
[Connection::PARAM_INT_ARRAY, Connection::PARAM_INT_ARRAY], [Connection::PARAM_INT_ARRAY, Connection::PARAM_INT_ARRAY],
...@@ -167,8 +162,7 @@ SQLDATA ...@@ -167,8 +162,7 @@ SQLDATA
ParameterType::INTEGER, ParameterType::INTEGER,
], ],
], ],
// Positional: Empty "integer" array DDC-1978 'Positional: Empty "integer" array (DDC-1978)' => [
[
'SELECT * FROM Foo WHERE foo IN (?)', 'SELECT * FROM Foo WHERE foo IN (?)',
[[]], [[]],
[Connection::PARAM_INT_ARRAY], [Connection::PARAM_INT_ARRAY],
...@@ -176,8 +170,7 @@ SQLDATA ...@@ -176,8 +170,7 @@ SQLDATA
[], [],
[], [],
], ],
// Positional: Empty "str" array DDC-1978 'Positional: Empty "str" array (DDC-1978)' => [
[
'SELECT * FROM Foo WHERE foo IN (?)', 'SELECT * FROM Foo WHERE foo IN (?)',
[[]], [[]],
[Connection::PARAM_STR_ARRAY], [Connection::PARAM_STR_ARRAY],
...@@ -185,17 +178,15 @@ SQLDATA ...@@ -185,17 +178,15 @@ SQLDATA
[], [],
[], [],
], ],
// Positional: explicit keys for params and types 'Positional: explicit keys for params and types' => [
[
'SELECT * FROM Foo WHERE foo = ? AND bar = ? AND baz = ?', 'SELECT * FROM Foo WHERE foo = ? AND bar = ? AND baz = ?',
[1 => 'bar', 2 => 'baz', 0 => 1], [1 => 'bar', 2 => 'baz', 0 => 1],
[2 => ParameterType::STRING, 1 => ParameterType::STRING], [2 => ParameterType::STRING, 1 => ParameterType::STRING],
'SELECT * FROM Foo WHERE foo = ? AND bar = ? AND baz = ?', 'SELECT * FROM Foo WHERE foo = ? AND bar = ? AND baz = ?',
[1 => 'bar', 0 => 1, 2 => 'baz'], [1 => 'bar', 0 => 1, 2 => 'baz'],
[1 => ParameterType::STRING, 2 => ParameterType::STRING], [1 => ParameterType::STRING, 2 => ParameterType::STRING, 0 => null],
], ],
// Positional: explicit keys for array params and array types 'Positional: explicit keys for array params and array types' => [
[
'SELECT * FROM Foo WHERE foo IN (?) AND bar IN (?) AND baz = ?', 'SELECT * FROM Foo WHERE foo IN (?) AND bar IN (?) AND baz = ?',
[1 => ['bar1', 'bar2'], 2 => true, 0 => [1, 2, 3]], [1 => ['bar1', 'bar2'], 2 => true, 0 => [1, 2, 3]],
[2 => ParameterType::BOOLEAN, 1 => Connection::PARAM_STR_ARRAY, 0 => Connection::PARAM_INT_ARRAY], [2 => ParameterType::BOOLEAN, 1 => Connection::PARAM_STR_ARRAY, 0 => Connection::PARAM_INT_ARRAY],
...@@ -210,8 +201,7 @@ SQLDATA ...@@ -210,8 +201,7 @@ SQLDATA
ParameterType::BOOLEAN, ParameterType::BOOLEAN,
], ],
], ],
// Positional starts from 1: One non-list before and one after list-needle 'Positional starts from 1: One non-list before and one after list-needle' => [
[
'SELECT * FROM Foo WHERE foo = ? AND bar IN (?) AND baz = ? AND foo IN (?)', 'SELECT * FROM Foo WHERE foo = ? AND bar IN (?) AND baz = ? AND foo IN (?)',
[1 => 1, 2 => [1, 2, 3], 3 => 4, 4 => [5, 6]], [1 => 1, 2 => [1, 2, 3], 3 => 4, 4 => [5, 6]],
[ [
...@@ -232,8 +222,7 @@ SQLDATA ...@@ -232,8 +222,7 @@ SQLDATA
ParameterType::INTEGER, ParameterType::INTEGER,
], ],
], ],
// Named parameters : Very simple with param int 'Named: Very simple with param int' => [
[
'SELECT * FROM Foo WHERE foo = :foo', 'SELECT * FROM Foo WHERE foo = :foo',
['foo' => 1], ['foo' => 1],
['foo' => ParameterType::INTEGER], ['foo' => ParameterType::INTEGER],
...@@ -241,9 +230,7 @@ SQLDATA ...@@ -241,9 +230,7 @@ SQLDATA
[1], [1],
[ParameterType::INTEGER], [ParameterType::INTEGER],
], ],
'Named: Very simple with param int and string' => [
// Named parameters : Very simple with param int and string
[
'SELECT * FROM Foo WHERE foo = :foo AND bar = :bar', 'SELECT * FROM Foo WHERE foo = :foo AND bar = :bar',
['bar' => 'Some String','foo' => 1], ['bar' => 'Some String','foo' => 1],
['foo' => ParameterType::INTEGER, 'bar' => ParameterType::STRING], ['foo' => ParameterType::INTEGER, 'bar' => ParameterType::STRING],
...@@ -251,8 +238,7 @@ SQLDATA ...@@ -251,8 +238,7 @@ SQLDATA
[1,'Some String'], [1,'Some String'],
[ParameterType::INTEGER, ParameterType::STRING], [ParameterType::INTEGER, ParameterType::STRING],
], ],
// Named parameters : Very simple with one needle 'Named: Very simple with one needle' => [
[
'SELECT * FROM Foo WHERE foo IN (:foo)', 'SELECT * FROM Foo WHERE foo IN (:foo)',
['foo' => [1, 2, 3]], ['foo' => [1, 2, 3]],
['foo' => Connection::PARAM_INT_ARRAY], ['foo' => Connection::PARAM_INT_ARRAY],
...@@ -260,8 +246,7 @@ SQLDATA ...@@ -260,8 +246,7 @@ SQLDATA
[1, 2, 3], [1, 2, 3],
[ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER], [ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER],
], ],
// Named parameters: One non-list before d one after list-needle 'Named: One non-list before d one after list-needle' => [
[
'SELECT * FROM Foo WHERE foo = :foo AND bar IN (:bar)', 'SELECT * FROM Foo WHERE foo = :foo AND bar IN (:bar)',
['foo' => 'string', 'bar' => [1, 2, 3]], ['foo' => 'string', 'bar' => [1, 2, 3]],
['foo' => ParameterType::STRING, 'bar' => Connection::PARAM_INT_ARRAY], ['foo' => ParameterType::STRING, 'bar' => Connection::PARAM_INT_ARRAY],
...@@ -269,8 +254,7 @@ SQLDATA ...@@ -269,8 +254,7 @@ SQLDATA
['string', 1, 2, 3], ['string', 1, 2, 3],
[ParameterType::STRING, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER], [ParameterType::STRING, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER],
], ],
// Named parameters: One non-list after list-needle 'Named: One non-list after list-needle' => [
[
'SELECT * FROM Foo WHERE bar IN (:bar) AND baz = :baz', 'SELECT * FROM Foo WHERE bar IN (:bar) AND baz = :baz',
['bar' => [1, 2, 3], 'baz' => 'foo'], ['bar' => [1, 2, 3], 'baz' => 'foo'],
['bar' => Connection::PARAM_INT_ARRAY, 'baz' => ParameterType::STRING], ['bar' => Connection::PARAM_INT_ARRAY, 'baz' => ParameterType::STRING],
...@@ -278,26 +262,39 @@ SQLDATA ...@@ -278,26 +262,39 @@ SQLDATA
[1, 2, 3, 'foo'], [1, 2, 3, 'foo'],
[ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING], [ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING],
], ],
// Named parameters: One non-list before and one after list-needle 'Named: One non-list before and one after list-needle' => [
[
'SELECT * FROM Foo WHERE foo = :foo AND bar IN (:bar) AND baz = :baz', 'SELECT * FROM Foo WHERE foo = :foo AND bar IN (:bar) AND baz = :baz',
['bar' => [1, 2, 3],'foo' => 1, 'baz' => 4], ['bar' => [1, 2, 3],'foo' => 1, 'baz' => 4],
['bar' => Connection::PARAM_INT_ARRAY, 'foo' => ParameterType::INTEGER, 'baz' => ParameterType::INTEGER], [
'bar' => Connection::PARAM_INT_ARRAY,
'foo' => ParameterType::INTEGER,
'baz' => ParameterType::INTEGER,
],
'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?) AND baz = ?', 'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?) AND baz = ?',
[1, 1, 2, 3, 4], [1, 1, 2, 3, 4],
[ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER], [
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::INTEGER,
],
], ],
// Named parameters: Two lists 'Named: Two lists' => [
[
'SELECT * FROM Foo WHERE foo IN (:a, :b)', 'SELECT * FROM Foo WHERE foo IN (:a, :b)',
['b' => [4, 5],'a' => [1, 2, 3]], ['b' => [4, 5],'a' => [1, 2, 3]],
['a' => Connection::PARAM_INT_ARRAY, 'b' => Connection::PARAM_INT_ARRAY], ['a' => Connection::PARAM_INT_ARRAY, 'b' => Connection::PARAM_INT_ARRAY],
'SELECT * FROM Foo WHERE foo IN (?, ?, ?, ?, ?)', 'SELECT * FROM Foo WHERE foo IN (?, ?, ?, ?, ?)',
[1, 2, 3, 4, 5], [1, 2, 3, 4, 5],
[ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER], [
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::INTEGER,
],
], ],
// Named parameters : With the same name arg type string 'Named: With the same name arg type string' => [
[
'SELECT * FROM Foo WHERE foo <> :arg AND bar = :arg', 'SELECT * FROM Foo WHERE foo <> :arg AND bar = :arg',
['arg' => 'Some String'], ['arg' => 'Some String'],
['arg' => ParameterType::STRING], ['arg' => ParameterType::STRING],
...@@ -305,18 +302,22 @@ SQLDATA ...@@ -305,18 +302,22 @@ SQLDATA
['Some String','Some String'], ['Some String','Some String'],
[ParameterType::STRING,ParameterType::STRING], [ParameterType::STRING,ParameterType::STRING],
], ],
// Named parameters : With the same name arg 'Named: With the same name arg' => [
[
'SELECT * FROM Foo WHERE foo IN (:arg) AND NOT bar IN (:arg)', 'SELECT * FROM Foo WHERE foo IN (:arg) AND NOT bar IN (:arg)',
['arg' => [1, 2, 3]], ['arg' => [1, 2, 3]],
['arg' => Connection::PARAM_INT_ARRAY], ['arg' => Connection::PARAM_INT_ARRAY],
'SELECT * FROM Foo WHERE foo IN (?, ?, ?) AND NOT bar IN (?, ?, ?)', 'SELECT * FROM Foo WHERE foo IN (?, ?, ?) AND NOT bar IN (?, ?, ?)',
[1, 2, 3, 1, 2, 3], [1, 2, 3, 1, 2, 3],
[ParameterType::INTEGER,ParameterType::INTEGER, ParameterType::INTEGER,ParameterType::INTEGER,ParameterType::INTEGER, ParameterType::INTEGER], [
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::INTEGER,
],
], ],
'Named: Same name, other name in between (DBAL-299)' => [
// Named parameters : Same name, other name in between DBAL-299
[
'SELECT * FROM Foo WHERE (:foo = 2) AND (:bar = 3) AND (:foo = 2)', 'SELECT * FROM Foo WHERE (:foo = 2) AND (:bar = 3) AND (:foo = 2)',
['foo' => 2,'bar' => 3], ['foo' => 2,'bar' => 3],
['foo' => ParameterType::INTEGER,'bar' => ParameterType::INTEGER], ['foo' => ParameterType::INTEGER,'bar' => ParameterType::INTEGER],
...@@ -324,8 +325,7 @@ SQLDATA ...@@ -324,8 +325,7 @@ SQLDATA
[2, 3, 2], [2, 3, 2],
[ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER], [ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER],
], ],
// Named parameters : Empty "integer" array DDC-1978 'Named: Empty "integer" array (DDC-1978)' => [
[
'SELECT * FROM Foo WHERE foo IN (:foo)', 'SELECT * FROM Foo WHERE foo IN (:foo)',
['foo' => []], ['foo' => []],
['foo' => Connection::PARAM_INT_ARRAY], ['foo' => Connection::PARAM_INT_ARRAY],
...@@ -333,8 +333,7 @@ SQLDATA ...@@ -333,8 +333,7 @@ SQLDATA
[], [],
[], [],
], ],
// Named parameters : Two empty "str" array DDC-1978 'Named: Two empty "str" array (DDC-1978)' => [
[
'SELECT * FROM Foo WHERE foo IN (:foo) OR bar IN (:bar)', 'SELECT * FROM Foo WHERE foo IN (:foo) OR bar IN (:bar)',
['foo' => [], 'bar' => []], ['foo' => [], 'bar' => []],
['foo' => Connection::PARAM_STR_ARRAY, 'bar' => Connection::PARAM_STR_ARRAY], ['foo' => Connection::PARAM_STR_ARRAY, 'bar' => Connection::PARAM_STR_ARRAY],
...@@ -358,8 +357,7 @@ SQLDATA ...@@ -358,8 +357,7 @@ SQLDATA
[1, 2, 'bar'], [1, 2, 'bar'],
[ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING], [ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING],
], ],
// Params/types with colons 'Params/types with colons' => [
[
'SELECT * FROM Foo WHERE foo = :foo OR bar = :bar', 'SELECT * FROM Foo WHERE foo = :foo OR bar = :bar',
[':foo' => 'foo', ':bar' => 'bar'], [':foo' => 'foo', ':bar' => 'bar'],
[':foo' => ParameterType::INTEGER], [':foo' => ParameterType::INTEGER],
...@@ -391,8 +389,7 @@ SQLDATA ...@@ -391,8 +389,7 @@ SQLDATA
[1, 2, 'bar'], [1, 2, 'bar'],
[ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING], [ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING],
], ],
// DBAL-522 - null valued parameters are not considered 'Null valued parameters (DBAL-522)' => [
[
'INSERT INTO Foo (foo, bar) values (:foo, :bar)', 'INSERT INTO Foo (foo, bar) values (:foo, :bar)',
['foo' => 1, 'bar' => null], ['foo' => 1, 'bar' => null],
[':foo' => ParameterType::INTEGER, ':bar' => ParameterType::NULL], [':foo' => ParameterType::INTEGER, ':bar' => ParameterType::NULL],
...@@ -408,8 +405,7 @@ SQLDATA ...@@ -408,8 +405,7 @@ SQLDATA
[1, null], [1, null],
[ParameterType::INTEGER, ParameterType::NULL], [ParameterType::INTEGER, ParameterType::NULL],
], ],
// DBAL-1205 - Escaped single quotes SQL- and C-Style 'Escaped single quotes SQL- and C-Style (DBAL-1205)' => [
[
"SELECT * FROM Foo WHERE foo = :foo||''':not_a_param''\\'' OR bar = ''':not_a_param''\\'':bar", "SELECT * FROM Foo WHERE foo = :foo||''':not_a_param''\\'' OR bar = ''':not_a_param''\\'':bar",
[':foo' => 1, ':bar' => 2], [':foo' => 1, ':bar' => 2],
[':foo' => ParameterType::INTEGER, 'bar' => ParameterType::INTEGER], [':foo' => ParameterType::INTEGER, 'bar' => ParameterType::INTEGER],
...@@ -417,6 +413,14 @@ SQLDATA ...@@ -417,6 +413,14 @@ SQLDATA
[1, 2], [1, 2],
[ParameterType::INTEGER, ParameterType::INTEGER], [ParameterType::INTEGER, ParameterType::INTEGER],
], ],
[
'SELECT NULL FROM dummy WHERE ? IN (?)',
['foo', ['bar', 'baz']],
[1 => Connection::PARAM_STR_ARRAY],
'SELECT NULL FROM dummy WHERE ? IN (?, ?)',
['foo', 'bar', 'baz'],
[null, ParameterType::STRING, ParameterType::STRING],
],
]; ];
} }
......
...@@ -4,6 +4,7 @@ namespace Doctrine\Tests\DBAL\Schema; ...@@ -4,6 +4,7 @@ namespace Doctrine\Tests\DBAL\Schema;
use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class ForeignKeyConstraintTest extends TestCase class ForeignKeyConstraintTest extends TestCase
...@@ -56,4 +57,30 @@ class ForeignKeyConstraintTest extends TestCase ...@@ -56,4 +57,30 @@ class ForeignKeyConstraintTest extends TestCase
[['FOO'], true], [['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 @@ ...@@ -3,13 +3,23 @@
namespace Doctrine\Tests\DBAL\Types; namespace Doctrine\Tests\DBAL\Types;
use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\ConversionException;
use Exception;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use stdClass; use stdClass;
use Throwable;
use function tmpfile; use function tmpfile;
class ConversionExceptionTest extends TestCase 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 * @param mixed $scalarValue
* *
...@@ -44,9 +54,19 @@ class ConversionExceptionTest extends TestCase ...@@ -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 public function testConversionFailedFormatPreservesPreviousException() : void
{ {
$previous = new Exception(); $previous = $this->createMock(Throwable::class);
$exception = ConversionException::conversionFailedFormat('foo', 'bar', 'baz', $previous); $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 ...@@ -5,6 +5,6 @@ set -ex
echo Installing driver dependencies echo Installing driver dependencies
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - 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 sudo apt-get update
ACCEPT_EULA=Y sudo apt-get install -qy msodbcsql17 unixodbc unixodbc-dev libssl1.0.0 ACCEPT_EULA=Y sudo apt-get install -qy msodbcsql17 unixodbc unixodbc-dev libssl1.0.0
...@@ -11,17 +11,17 @@ ...@@ -11,17 +11,17 @@
<ini name="error_reporting" value="-1" /> <ini name="error_reporting" value="-1" />
<var name="db_type" value="pdo_mysql"/> <var name="db_type" value="pdo_mysql"/>
<var name="db_host" value="localhost" /> <var name="db_host" value="127.0.0.1" />
<var name="db_username" value="travis" /> <var name="db_username" value="root" />
<var name="db_password" value="" /> <var name="db_password" value="" />
<var name="db_name" value="doctrine_tests" /> <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_type" value="pdo_mysql"/>
<var name="tmpdb_host" value="localhost" /> <var name="tmpdb_host" value="127.0.0.1" />
<var name="tmpdb_username" value="travis" /> <var name="tmpdb_username" value="root" />
<var name="tmpdb_password" value="" /> <var name="tmpdb_password" value="" />
<var name="tmpdb_port" value="3306"/> <var name="tmpdb_port" value="33306"/>
</php> </php>
<testsuites> <testsuites>
......
...@@ -11,17 +11,17 @@ ...@@ -11,17 +11,17 @@
<ini name="error_reporting" value="-1" /> <ini name="error_reporting" value="-1" />
<var name="db_type" value="mysqli"/> <var name="db_type" value="mysqli"/>
<var name="db_host" value="localhost" /> <var name="db_host" value="127.0.0.1" />
<var name="db_username" value="travis" /> <var name="db_username" value="root" />
<var name="db_password" value="" /> <var name="db_password" value="" />
<var name="db_name" value="doctrine_tests" /> <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_type" value="mysqli"/>
<var name="tmpdb_host" value="localhost" /> <var name="tmpdb_host" value="127.0.0.1" />
<var name="tmpdb_username" value="travis" /> <var name="tmpdb_username" value="root" />
<var name="tmpdb_password" value="" /> <var name="tmpdb_password" value="" />
<var name="tmpdb_port" value="3306"/> <var name="tmpdb_port" value="33306"/>
</php> </php>
<testsuites> <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