diff --git a/.scrutinizer.yml b/.scrutinizer.yml
index 56a0bf721ab..a752eb67887 100644
--- a/.scrutinizer.yml
+++ b/.scrutinizer.yml
@@ -3,7 +3,7 @@ build:
analysis:
environment:
php:
- version: 7.1
+ version: 7.2
cache:
disabled: false
directories:
diff --git a/.travis.yml b/.travis.yml
index 4d30bbd11c3..c615b4353a8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,6 @@ cache:
- $HOME/.composer/cache
php:
- - 7.1
- 7.2
- nightly
@@ -35,12 +34,6 @@ jobs:
- stage: Coding standard
include:
- - stage: Test
- php: 7.1
- env: DB=mysql MYSQL_VERSION=5.7
- sudo: required
- before_script:
- - bash ./tests/travis/install-mysql-5.7.sh
- stage: Test
php: 7.2
env: DB=mysql MYSQL_VERSION=5.7
@@ -54,12 +47,6 @@ jobs:
before_script:
- bash ./tests/travis/install-mysql-5.7.sh
- - stage: Test
- php: 7.1
- env: DB=mysqli MYSQL_VERSION=5.7
- sudo: required
- before_script:
- - bash ./tests/travis/install-mysql-5.7.sh
- stage: Test
php: 7.2
env: DB=mysqli MYSQL_VERSION=5.7
@@ -73,11 +60,6 @@ jobs:
before_script:
- bash ./tests/travis/install-mysql-5.7.sh
- - stage: Test
- php: 7.1
- env: DB=mariadb MARIADB_VERSION=10.0
- addons:
- mariadb: 10.0
- stage: Test
php: 7.2
env: DB=mariadb MARIADB_VERSION=10.0
@@ -89,11 +71,6 @@ jobs:
addons:
mariadb: 10.0
- - stage: Test
- php: 7.1
- env: DB=mariadb MARIADB_VERSION=10.1
- addons:
- mariadb: 10.1
- stage: Test
php: 7.2
env: DB=mariadb MARIADB_VERSION=10.1
@@ -105,11 +82,6 @@ jobs:
addons:
mariadb: 10.1
- - stage: Test
- php: 7.1
- env: DB=mariadb MARIADB_VERSION=10.2
- addons:
- mariadb: 10.2
- stage: Test
php: 7.2
env: DB=mariadb MARIADB_VERSION=10.2
@@ -121,11 +93,6 @@ jobs:
addons:
mariadb: 10.2
- - stage: Test
- php: 7.1
- env: DB=mariadb.mysqli MARIADB_VERSION=10.2
- addons:
- mariadb: 10.2
- stage: Test
php: 7.2
env: DB=mariadb.mysqli MARIADB_VERSION=10.2
@@ -137,35 +104,6 @@ jobs:
addons:
mariadb: 10.2
- - stage: Test
- php: 7.1
- env: DB=pgsql POSTGRESQL_VERSION=9.2
- services:
- - postgresql
- addons:
- postgresql: "9.2"
- - stage: Test
- php: 7.2
- env: DB=pgsql POSTGRESQL_VERSION=9.2
- services:
- - postgresql
- addons:
- postgresql: "9.2"
- - stage: Test
- php: nightly
- env: DB=pgsql POSTGRESQL_VERSION=9.2
- services:
- - postgresql
- addons:
- postgresql: "9.2"
-
- - stage: Test
- php: 7.1
- env: DB=pgsql POSTGRESQL_VERSION=9.3
- services:
- - postgresql
- addons:
- postgresql: "9.3"
- stage: Test
php: 7.2
env: DB=pgsql POSTGRESQL_VERSION=9.3
@@ -181,13 +119,6 @@ jobs:
addons:
postgresql: "9.3"
- - stage: Test
- php: 7.1
- env: DB=pgsql POSTGRESQL_VERSION=9.4
- services:
- - postgresql
- addons:
- postgresql: "9.4"
- stage: Test
php: 7.2
env: DB=pgsql POSTGRESQL_VERSION=9.4
@@ -203,13 +134,6 @@ jobs:
addons:
postgresql: "9.4"
- - stage: Test
- php: 7.1
- env: DB=pgsql POSTGRESQL_VERSION=9.5
- services:
- - postgresql
- addons:
- postgresql: "9.5"
- stage: Test
php: 7.2
env: DB=pgsql POSTGRESQL_VERSION=9.5
@@ -225,13 +149,6 @@ jobs:
addons:
postgresql: "9.5"
- - stage: Test
- php: 7.1
- env: DB=pgsql POSTGRESQL_VERSION=9.6
- services:
- - postgresql
- addons:
- postgresql: "9.6"
- stage: Test
php: 7.2
env: DB=pgsql POSTGRESQL_VERSION=9.6
@@ -247,16 +164,6 @@ jobs:
addons:
postgresql: "9.6"
- - stage: Test
- php: 7.1
- env: DB=pgsql POSTGRESQL_VERSION=10.0
- sudo: required
- services:
- - postgresql
- addons:
- postgresql: "9.6"
- before_script:
- - bash ./tests/travis/install-postgres-10.sh
- stage: Test
php: 7.2
env: DB=pgsql POSTGRESQL_VERSION=10.0
@@ -278,14 +185,6 @@ jobs:
before_script:
- bash ./tests/travis/install-postgres-10.sh
- - stage: Test
- env: DB=sqlsrv
- sudo: required
- services:
- - docker
- before_script:
- - bash ./tests/travis/install-mssql-$DB.sh
- - bash ./tests/travis/install-mssql.sh
- stage: Test
php: 7.2
env: DB=sqlsrv
@@ -296,15 +195,6 @@ jobs:
- bash ./tests/travis/install-mssql-$DB.sh
- bash ./tests/travis/install-mssql.sh
- - stage: Test
- php: 7.1
- env: DB=pdo_sqlsrv
- sudo: required
- services:
- - docker
- before_script:
- - bash ./tests/travis/install-mssql-$DB.sh
- - bash ./tests/travis/install-mssql.sh
- stage: Test
php: 7.2
env: DB=pdo_sqlsrv
@@ -316,7 +206,7 @@ jobs:
- bash ./tests/travis/install-mssql.sh
- stage: Test
- php: 7.1
+ php: 7.2
env: DB=sqlite DEPENDENCIES=low
install:
- travis_retry composer update --prefer-dist --prefer-lowest
@@ -330,7 +220,7 @@ jobs:
- travis_retry composer update --prefer-dist
- stage: Coverage
- php: 7.1
+ php: 7.2
env: DB=sqlite
before_script:
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,}
@@ -343,7 +233,7 @@ jobs:
- stage: Pull request coding standard
if: type = pull_request
- php: 7.1
+ php: 7.2
install: travis_retry composer install --prefer-dist
script:
- |
@@ -357,7 +247,7 @@ jobs:
- stage: Coding standard
if: NOT type = pull_request
- php: 7.1
+ php: 7.2
install: travis_retry composer install --prefer-dist
script:
- ./vendor/bin/phpcs
diff --git a/UPGRADE.md b/UPGRADE.md
index cc238ee34ac..17ddd8832d9 100644
--- a/UPGRADE.md
+++ b/UPGRADE.md
@@ -1,3 +1,107 @@
+# Upgrade to 3.0 (DEVELOP)
+
+## BC BREAK: Removed MsSQLKeywords class
+
+The `Doctrine\DBAL\Platforms\MsSQLKeywords` has been removed.
+Please use `Doctrine\DBAL\Platforms\SQLServerPlatform `instead.
+
+## BC BREAK: Removed PDO DB2 driver
+
+This PDO-based IBM DB2 driver (built on top of pdo_ibm extension) has already been unsupported as of 2.5, it has now been now removed.
+
+The following class has been removed:
+
+ * `Doctrine\DBAL\Driver\PDOIbm\Driver`
+
+## BC BREAK: Removed support for SQL Anywhere 12 and older
+
+DBAL now requires SQL Anywhere 16 or newer, support for unmaintained versions has been dropped.
+If you are using any of the legacy versions, you have to upgrade to newer SQL Anywhere version (16+).
+`Doctrine\DBAL\Platforms\SQLAnywherePlatform` and `Doctrine\DBAL\Platforms\Keywords\SQLAnywhereKeywords` now represent the SQL Anywhere 16.
+
+The following classes have been removed:
+
+ * `Doctrine\DBAL\Platforms\SQLAnywhere11Platform`
+ * `Doctrine\DBAL\Platforms\SQLAnywhere12Platform`
+ * `Doctrine\DBAL\Platforms\SQLAnywhere16Platform`
+ * `Doctrine\DBAL\Platforms\Keywords\SQLAnywhere11Keywords`
+ * `Doctrine\DBAL\Platforms\Keywords\SQLAnywhere12Keywords`
+ * `Doctrine\DBAL\Platforms\Keywords\SQLAnywhere16Keywords`
+
+## BC BREAK: Removed support for SQL Server 2005 and older
+
+DBAL now requires SQL Server 2008 or newer, support for unmaintained versions has been dropped.
+If you are using any of the legacy versions, you have to upgrade to newer SQL Server version (2012+ is recommended).
+`Doctrine\DBAL\Platforms\SQLServerPlatform` and `Doctrine\DBAL\Platforms\Keywords\SQLServerKeywords` now represent the SQL Server 2008.
+
+The following classes have been removed:
+
+ * `Doctrine\DBAL\Platforms\SQLServer2005Platform`
+ * `Doctrine\DBAL\Platforms\SQLServer2008Platform`
+ * `Doctrine\DBAL\Platforms\Keywords\SQLServer2005Keywords`
+ * `Doctrine\DBAL\Platforms\Keywords\SQLServer2008Keywords`
+
+## BC BREAK: Removed support for PostgreSQL 9.2 and older
+
+DBAL now requires PostgeSQL 9.3 or newer, support for unmaintained versions has been dropped.
+If you are using any of the legacy versions, you have to upgrade to newer PostgreSQL version (9.6+ is recommended).
+`Doctrine\DBAL\Platforms\PostgreSqlPlatform` and `Doctrine\DBAL\Platforms\Keywords\PostgreSQLKeywords` now represent the PostgreSQL 9.3.
+
+The following classes have been removed:
+
+ * `Doctrine\DBAL\Platforms\PostgreSQL91Platform`
+ * `Doctrine\DBAL\Platforms\PostgreSQL92Platform`
+ * `Doctrine\DBAL\Platforms\Keywords\PostgreSQL91Keywords`
+ * `Doctrine\DBAL\Platforms\Keywords\PostgreSQL92Keywords`
+
+## BC BREAK: Removed Doctrine\DBAL\Version
+
+The Doctrine\DBAL\Version class is no longer available: please refrain from checking the DBAL version at runtime.
+
+## BC BREAK: the PDO symbols are no longer part of the DBAL API
+
+1. The support of `PDO::PARAM_*`, `PDO::FETCH_*`, `PDO::CASE_*` and `PDO::PARAM_INPUT_OUTPUT` constants in the DBAL API is removed.
+2. `\Doctrine\DBAL\Driver\PDOConnection` does not extend `\PDO` anymore. Please use `\Doctrine\DBAL\Driver\PDOConnection::getWrappedConnection()` to access the underlying `PDO` object.
+3. `\Doctrine\DBAL\Driver\PDOStatement` does not extend `\PDOStatement` anymore.
+
+Before:
+
+ use Doctrine\DBAL\Portability\Connection;
+
+ $params = array(
+ 'wrapperClass' => Connection::class,
+ 'fetch_case' => PDO::CASE_LOWER,
+ );
+
+ $stmt->bindValue(1, 1, PDO::PARAM_INT);
+ $stmt->fetchAll(PDO::FETCH_COLUMN);
+
+After:
+
+ use Doctrine\DBAL\ColumnCase;
+ use Doctrine\DBAL\FetchMode;
+ use Doctrine\DBAL\ParameterType;
+ use Doctrine\DBAL\Portability\Connection;
+
+ $params = array(
+ 'wrapperClass' => Connection::class,
+ 'fetch_case' => ColumnCase::LOWER,
+ );
+
+ $stmt->bindValue(1, 1, ParameterType::INTEGER);
+ $stmt->fetchAll(FetchMode::COLUMN);
+
+## BC BREAK: Removed Drizzle support
+
+The Drizzle project is abandoned and is therefore not supported by Doctrine DBAL anymore.
+
+## BC BREAK: SQLLogger changes
+
+- The `SQLLogger` interface has changed; the methods are the same but use scalar type hints, return types, and non-nullable arrays.
+- `SQLLogger` implementations: `DebugStack`, `EchoSQLLogger`, `LoggerChain` are now final.
+- `Configuration::getSQLLogger()` does not return `null` anymore, but a `NullLogger` implementation.
+- `Configuration::setSQLLogger()` does not allow `null` anymore.
+
# Upgrade to 2.7
## Doctrine\DBAL\Platforms\AbstractPlatform::DATE_INTERVAL_UNIT_* constants deprecated
diff --git a/build.properties b/build.properties
index 309e0e2105c..e69de29bb2d 100644
--- a/build.properties
+++ b/build.properties
@@ -1,3 +0,0 @@
-# Version class and file
-project.version_class = Doctrine\\DBAL\\Version
-project.version_file = lib/Doctrine/DBAL/Version.php
diff --git a/build.xml b/build.xml
index 064a6084e7e..95f80d42398 100644
--- a/build.xml
+++ b/build.xml
@@ -38,29 +38,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/composer.json b/composer.json
index 6e73c336fe4..385511fe524 100644
--- a/composer.json
+++ b/composer.json
@@ -12,9 +12,9 @@
{"name": "Jonathan Wage", "email": "jonwage@gmail.com"}
],
"require": {
- "php": "^7.1",
- "ext-pdo": "*",
- "doctrine/common": "^2.7.1"
+ "php": "^7.2",
+ "doctrine/common": "^2.7.1",
+ "ocramius/package-versions": "^1.2"
},
"require-dev": {
"doctrine/coding-standard": "^4.0",
@@ -38,7 +38,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "2.8.x-dev"
+ "dev-master": "3.0.x-dev"
}
},
"archive": {
diff --git a/docs/en/reference/configuration.rst b/docs/en/reference/configuration.rst
index 88f0069506a..6328a581b2d 100644
--- a/docs/en/reference/configuration.rst
+++ b/docs/en/reference/configuration.rst
@@ -73,12 +73,8 @@ full driver name::
pdo-mysql://localhost:4486/foo?charset=UTF-8
-If you wanted to use the ``drizzle_pdo__mysql`` driver instead::
-
- drizzle-pdo-mysql://localhost:4486/foo?charset=UTF-8
-
-In the last two examples above, mind the dashes instead of the
-underscores in the URL schemes.
+In the example above, mind the dashes instead of the
+underscores in the URL scheme.
For connecting to an SQLite database, the authority portion of the
URL is obviously irrelevant and thus can be omitted. The path part
@@ -128,8 +124,6 @@ interfaces to use. It can be configured in one of three ways:
- ``pdo_mysql``: A MySQL driver that uses the pdo\_mysql PDO
extension.
- - ``drizzle_pdo_mysql``: A Drizzle driver that uses pdo\_mysql PDO
- extension.
- ``mysqli``: A MySQL driver that uses the mysqli extension.
- ``pdo_sqlite``: An SQLite driver that uses the pdo\_sqlite PDO
extension.
@@ -198,23 +192,6 @@ pdo\_mysql
- ``charset`` (string): The charset used when connecting to the
database.
-drizzle\_pdo\_mysql
-^^^^^^^^^^^^^^^^^^^
-
-**Requires** drizzle plugin ``mysql_protocol`` or ``mysql_unix_socket_protocol`` to be enabled.
-On Ubuntu this can be done by editing ``/etc/drizzle/conf.d/mysql-protocol.cnf``
-or ``/etc/drizzle/conf.d/mysql-unix-socket-protocol.cnf`` and restarting the drizzled daemon.
-
-- ``user`` (string): Username to use when connecting to the
- database. Only needed if authentication is configured for drizzled.
-- ``password`` (string): Password to use when connecting to the
- database. Only needed if authentication is configured for drizzled.
-- ``host`` (string): Hostname of the database to connect to.
-- ``port`` (integer): Port of the database to connect to.
-- ``dbname`` (string): Name of the database/schema to connect to.
-- ``unix_socket`` (string): Name of the socket used to connect to
- the database.
-
mysqli
^^^^^^
@@ -253,20 +230,20 @@ pdo\_pgsql
- ``sslmode`` (string): Determines whether or with what priority
a SSL TCP/IP connection will be negotiated with the server.
See the list of available modes:
- `http://www.postgresql.org/docs/9.1/static/libpq-connect.html#LIBPQ-CONNECT-SSLMODE`
+ `https://www.postgresql.org/docs/9.3/static/libpq-connect.html#LIBPQ-CONNECT-SSLMODE`
- ``sslrootcert`` (string): specifies the name of a file containing
SSL certificate authority (CA) certificate(s). If the file exists,
the server's certificate will be verified to be signed by one of these
authorities.
- See http://www.postgresql.org/docs/9.0/static/libpq-connect.html#LIBPQ-CONNECT-SSLROOTCERT
+ See https://www.postgresql.org/docs/9.3/static/libpq-connect.html#LIBPQ-CONNECT-SSLROOTCERT
- ``sslcert`` (string): specifies the file name of the client SSL certificate.
- See `https://www.postgresql.org/docs/9.1/static/libpq-connect.html#LIBPQ-CONNECT-SSLCERT`
+ See `https://www.postgresql.org/docs/9.3/static/libpq-connect.html#LIBPQ-CONNECT-SSLCERT`
- ``sslkey`` (string): specifies the location for the secret key used for the
client certificate.
- See `https://www.postgresql.org/docs/9.1/static/libpq-connect.html#LIBPQ-CONNECT-SSLKEY`
+ See `https://www.postgresql.org/docs/9.3/static/libpq-connect.html#LIBPQ-CONNECT-SSLKEY`
- ``sslcrl`` (string): specifies the file name of the SSL certificate
revocation list (CRL).
- See `https://www.postgresql.org/docs/9.1/static/libpq-connect.html#LIBPQ-CONNECT-SSLCRL`
+ See `https://www.postgresql.org/docs/9.3/static/libpq-connect.html#LIBPQ-CONNECT-SSLCRL`
- ``application_name`` (string): Name of the application that is
connecting to database. Optional. It will be displayed at ``pg_stat_activity``.
@@ -334,14 +311,9 @@ sqlanywhere
Depending on the used underlying platform version, you can specify
any other connection parameter that is supported by the particular
platform version via the ``driverOptions`` option.
-You can find a list of supported connection parameters for each
-platform version here:
-
-- `SQL Anywhere 10.0.1 `_
-- `SQL Anywhere 11.0.0 `_
-- `SQL Anywhere 11.0.1 `_
-- `SQL Anywhere 12.0.0 `_
-- `SQL Anywhere 12.0.1 `_
+You can find a list of supported connection parameters for the
+currently supported platform here:
+
- `SAP Sybase SQL Anywhere 16.0 `_
Automatic platform version detection
diff --git a/docs/en/reference/introduction.rst b/docs/en/reference/introduction.rst
index e52f7fff858..97b8c2bff5f 100644
--- a/docs/en/reference/introduction.rst
+++ b/docs/en/reference/introduction.rst
@@ -21,7 +21,6 @@ The following database vendors are currently supported:
- PostgreSQL
- SAP Sybase SQL Anywhere
- SQLite
-- Drizzle
The Doctrine 2 database layer can be used independently of the
object-relational mapper. In order to use the DBAL all you need is
diff --git a/docs/en/reference/platforms.rst b/docs/en/reference/platforms.rst
index 2505680f7ce..fb84437abad 100644
--- a/docs/en/reference/platforms.rst
+++ b/docs/en/reference/platforms.rst
@@ -44,18 +44,15 @@ Oracle
Microsoft SQL Server
^^^^^^^^^^^^^^^^^^^^
-- ``SQLServerPlatform`` for version 2000 and above.
-- ``SQLServer2005Platform`` for version 2005 and above.
-- ``SQLServer2008Platform`` for version 2008 and above.
+- ``SQLServerPlatform`` for version 2008 and above.
- ``SQLServer2012Platform`` for version 2012 and above.
PostgreSQL
^^^^^^^^^^
- ``PostgreSqlPlatform`` for all versions.
-- ``PostgreSQL91Platform`` for version 9.1 and above.
-- ``PostgreSQL92Platform`` for version 9.2 and above.
- ``PostgreSQL94Platform`` for version 9.4 and above.
+- ``PostgreSQL100Platform`` for version 10.0 and above.
SAP Sybase SQL Anywhere
^^^^^^^^^^^^^^^^^^^^^^^
@@ -70,11 +67,6 @@ SQLite
- ``SqlitePlatform`` for all versions.
-Drizzle
-^^^^^^
-
-- ``DrizzlePlatform`` for all versions.
-
It is highly encouraged to use the platform class that matches your
database vendor and version best. Otherwise it is not guaranteed
that the compatibility in terms of SQL dialect and feature support
diff --git a/docs/en/reference/schema-representation.rst b/docs/en/reference/schema-representation.rst
index b250a5c5109..381a997e321 100644
--- a/docs/en/reference/schema-representation.rst
+++ b/docs/en/reference/schema-representation.rst
@@ -115,10 +115,10 @@ The following options are not completely portable but are supported by most of t
vendors:
- **unsigned** (boolean): Whether a ``smallint``, ``integer`` or ``bigint`` Doctrine
- type column should allow unsigned values only. Supported by MySQL, SQL Anywhere
- and Drizzle. Defaults to ``false``.
+ type column should allow unsigned values only. Supported by MySQL and SQL Anywhere.
+ Defaults to ``false``.
- **comment** (integer|string): The column comment. Supported by MySQL, PostgreSQL,
- Oracle, SQL Server, SQL Anywhere and Drizzle. Defaults to ``null``.
+ Oracle, SQL Server and SQL Anywhere. Defaults to ``null``.
Vendor specific options
^^^^^^^^^^^^^^^^^^^^^^^
@@ -133,8 +133,8 @@ The following options are completely vendor specific and absolutely not portable
supported by some vendors but not portable:
- **charset** (string): The character set to use for the column. Currently only supported
- on MySQL and Drizzle.
+ on MySQL.
- **collation** (string): The collation to use for the column. Supported by MySQL, PostgreSQL,
- Sqlite, SQL Server and Drizzle.
+ Sqlite and SQL Server.
- **check** (string): The check constraint clause to add to the column.
Defaults to ``null``.
diff --git a/docs/en/reference/types.rst b/docs/en/reference/types.rst
index f4916a69672..dd733f33a51 100644
--- a/docs/en/reference/types.rst
+++ b/docs/en/reference/types.rst
@@ -517,8 +517,6 @@ Please also notice the mapping specific footnotes for additional information.
+===================+===============+==========================+=========+==========================================================+
| **smallint** | ``integer`` | **MySQL** | *all* | ``SMALLINT`` ``UNSIGNED`` [10]_ ``AUTO_INCREMENT`` [11]_ |
| | +--------------------------+---------+----------------------------------------------------------+
-| | | **Drizzle** | *all* | ``INT`` ``UNSIGNED`` [10]_ ``AUTO_INCREMENT`` [11]_ |
-| | +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | *all* | ``SMALLINT`` |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``NUMBER(5)`` |
@@ -527,11 +525,9 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Anywhere** | *all* | ``UNSIGNED`` [10]_ ``SMALLINT`` ``IDENTITY`` [11]_ |
| | +--------------------------+---------+----------------------------------------------------------+
-| | | **SQLite** | *all* | ``INTEGER`` [16]_ |
+| | | **SQLite** | *all* | ``INTEGER`` [15]_ |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **integer** | ``integer`` | **MySQL** | *all* | ``INT`` ``UNSIGNED`` [10]_ ``AUTO_INCREMENT`` [11]_ |
-| | +--------------------------+ | |
-| | | **Drizzle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | *all* | ``INT`` [12]_ |
| | | | +----------------------------------------------------------+
@@ -543,12 +539,10 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Anywhere** | *all* | ``UNSIGNED`` [10]_ ``INT`` ``IDENTITY`` [11]_ |
| | +--------------------------+---------+----------------------------------------------------------+
-| | | **SQLite** | *all* | ``INTEGER`` [16]_ |
+| | | **SQLite** | *all* | ``INTEGER`` [15]_ |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **bigint** | ``string`` | **MySQL** | *all* | ``BIGINT`` ``UNSIGNED`` [10]_ ``AUTO_INCREMENT`` [11]_ |
-| | [8]_ +--------------------------+ | |
-| | | **Drizzle** | | |
-| | +--------------------------+---------+----------------------------------------------------------+
+| | [8]_ +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | *all* | ``BIGINT`` [12]_ |
| | | | +----------------------------------------------------------+
| | | | | ``BIGSERIAL`` [11]_ |
@@ -559,7 +553,7 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Anywhere** | *all* | ``UNSIGNED`` [10]_ ``BIGINT`` ``IDENTITY`` [11]_ |
| | +--------------------------+---------+----------------------------------------------------------+
-| | | **SQLite** | *all* | ``INTEGER`` [16]_ |
+| | | **SQLite** | *all* | ``INTEGER`` [15]_ |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **decimal** [7]_ | ``string`` | **MySQL** | *all* | ``NUMERIC(p, s)`` ``UNSIGNED`` [10]_ |
| | [9]_ +--------------------------+---------+----------------------------------------------------------+
@@ -572,8 +566,6 @@ Please also notice the mapping specific footnotes for additional information.
| | | **SQL Anywhere** | | |
| | +--------------------------+ | |
| | | **SQLite** | | |
-| | +--------------------------+ | |
-| | | **Drizzle** | | |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **float** | ``float`` | **MySQL** | *all* | ``DOUBLE PRECISION`` ``UNSIGNED`` [10]_ |
| | +--------------------------+---------+----------------------------------------------------------+
@@ -586,8 +578,6 @@ Please also notice the mapping specific footnotes for additional information.
| | | **SQL Anywhere** | | |
| | +--------------------------+ | |
| | | **SQLite** | | |
-| | +--------------------------+ | |
-| | | **Drizzle** | | |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **string** | ``string`` | **MySQL** | *all* | ``VARCHAR(n)`` [3]_ |
| [2]_ [5]_ | +--------------------------+ | |
@@ -597,8 +587,6 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+ | |
| | | **SQLite** | | |
| | +--------------------------+---------+----------------------------------------------------------+
-| | | **Drizzle** | *all* | ``VARCHAR(n)`` |
-| | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``VARCHAR2(n)`` [3]_ |
| | | | +----------------------------------------------------------+
| | | | | ``CHAR(n)`` [4]_ |
@@ -607,19 +595,17 @@ Please also notice the mapping specific footnotes for additional information.
| | | | +----------------------------------------------------------+
| | | | | ``NCHAR(n)`` [4]_ |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
-| **text** | ``string`` | **MySQL** | *all* | ``TINYTEXT`` [17]_ |
+| **text** | ``string`` | **MySQL** | *all* | ``TINYTEXT`` [16]_ |
| | | | +----------------------------------------------------------+
-| | | | | ``TEXT`` [18]_ |
+| | | | | ``TEXT`` [17]_ |
| | | | +----------------------------------------------------------+
-| | | | | ``MEDIUMTEXT`` [19]_ |
+| | | | | ``MEDIUMTEXT`` [18]_ |
| | | | +----------------------------------------------------------+
-| | | | | ``LONGTEXT`` [20]_ |
+| | | | | ``LONGTEXT`` [19]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | *all* | ``TEXT`` |
| | +--------------------------+ | |
| | | **SQL Anywhere** | | |
-| | +--------------------------+ | |
-| | | **Drizzle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``CLOB`` |
| | +--------------------------+ | |
@@ -632,8 +618,6 @@ Please also notice the mapping specific footnotes for additional information.
| | | **Oracle** | | |
| | +--------------------------+ | |
| | | **SQLite** | | |
-| | +--------------------------+ | |
-| | | **Drizzle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Server** | *all* | ``UNIQUEIDENTIFIER`` |
| | +--------------------------+ | |
@@ -647,27 +631,23 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+ | ``BINARY(n)`` [4]_ |
| | | **SQL Anywhere** | | |
| | +--------------------------+---------+----------------------------------------------------------+
-| | | **Drizzle** | *all* | ``VARBINARY(n)`` |
-| | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``RAW(n)`` |
| | +--------------------------+---------+----------------------------------------------------------+
-| | | **PostgreSQL** | *all* | ``BYTEA`` [16]_ |
+| | | **PostgreSQL** | *all* | ``BYTEA`` [15]_ |
| | +--------------------------+---------+----------------------------------------------------------+
-| | | **SQLite** | *all* | ``BLOB`` [16]_ |
+| | | **SQLite** | *all* | ``BLOB`` [15]_ |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
-| **blob** | ``resource`` | **MySQL** | *all* | ``TINYBLOB`` [17]_ |
+| **blob** | ``resource`` | **MySQL** | *all* | ``TINYBLOB`` [16]_ |
| | | | +----------------------------------------------------------+
-| | | | | ``BLOB`` [18]_ |
+| | | | | ``BLOB`` [17]_ |
| | | | +----------------------------------------------------------+
-| | | | | ``MEDIUMBLOB`` [19]_ |
+| | | | | ``MEDIUMBLOB`` [18]_ |
| | | | +----------------------------------------------------------+
-| | | | | ``LONGBLOB`` [20]_ |
+| | | | | ``LONGBLOB`` [19]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``BLOB`` |
| | +--------------------------+ | |
| | | **SQLite** | | |
-| | +--------------------------+ | |
-| | | **Drizzle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Server** | *all* | ``VARBINARY(MAX)`` |
| | +--------------------------+---------+----------------------------------------------------------+
@@ -680,8 +660,6 @@ Please also notice the mapping specific footnotes for additional information.
| | | **PostgreSQL** | *all* | ``BOOLEAN`` |
| | +--------------------------+ | |
| | | **SQLite** | | |
-| | +--------------------------+ | |
-| | | **Drizzle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Server** | *all* | ``BIT`` |
| | +--------------------------+ | |
@@ -698,16 +676,10 @@ Please also notice the mapping specific footnotes for additional information.
| | | **SQL Anywhere** | | |
| | +--------------------------+ | |
| | | **SQLite** | | |
-| | +--------------------------+ | |
-| | | **Drizzle** | | |
| | +--------------------------+---------+ |
-| | | **SQL Server** | >= 2008 | |
-| | | +---------+----------------------------------------------------------+
-| | | | < 2008 | ``DATETIME`` [16]_ |
+| | | **SQL Server** | "all" | |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **datetime** | ``\DateTime`` | **MySQL** | *all* | ``DATETIME`` [13]_ |
-| | +--------------------------+ +----------------------------------------------------------+
-| | | **Drizzle** | | ``TIMESTAMP`` [14]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Server** | *all* | ``DATETIME`` |
| | +--------------------------+ | |
@@ -719,53 +691,41 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``TIMESTAMP(0)`` |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
-| **datetimetz** | ``\DateTime`` | **MySQL** | *all* | ``DATETIME`` [15]_ [16]_ |
-| | +--------------------------+ | |
-| | | **Drizzle** | | |
+| **datetimetz** | ``\DateTime`` | **MySQL** | *all* | ``DATETIME`` [14]_ [15]_ |
| | +--------------------------+ | |
| | | **SQLite** | | |
| | +--------------------------+---------+ |
-| | | **SQL Server** | < 2008 | |
-| | | +---------+----------------------------------------------------------+
-| | | | >= 2008 | ``DATETIMEOFFSET(6)`` |
+| | | **SQL Server** | "all" | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | *all* | ``TIMESTAMP(0) WITH TIME ZONE`` |
| | +--------------------------+ | |
| | | **Oracle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
-| | | **SQL Anywhere** | < 12 | ``DATETIME`` [15]_ [16]_ |
-| | | +---------+----------------------------------------------------------+
-| | | | >= 12 | ``TIMESTAMP WITH TIME ZONE`` |
+| | | **SQL Anywhere** | "all" | ``TIMESTAMP WITH TIME ZONE`` |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **time** | ``\DateTime`` | **MySQL** | *all* | ``TIME`` |
| | +--------------------------+ | |
| | | **SQL Anywhere** | | |
| | +--------------------------+ | |
| | | **SQLite** | | |
-| | +--------------------------+ | |
-| | | **Drizzle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | *all* | ``TIME(0) WITHOUT TIME ZONE`` |
| | +--------------------------+---------+----------------------------------------------------------+
-| | | **Oracle** | *all* | ``DATE`` [16]_ |
+| | | **Oracle** | *all* | ``DATE`` [15]_ |
| | +--------------------------+---------+----------------------------------------------------------+
-| | | **SQL Server** | < 2008 | ``DATETIME`` [16]_ |
-| | | +---------+----------------------------------------------------------+
-| | | | >= 2008 | ``TIME(0)`` |
+| | | **SQL Server** | "all" | ``TIME(0)`` |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
-| **array** [1]_ | ``array`` | **MySQL** | *all* | ``TINYTEXT`` [17]_ |
+| **array** [1]_ | ``array`` | **MySQL** | *all* | ``TINYTEXT`` [16]_ |
+-------------------+ | | +----------------------------------------------------------+
-| **simple array** | | | | ``TEXT`` [18]_ |
+| **simple array** | | | | ``TEXT`` [17]_ |
| [1]_ | | | +----------------------------------------------------------+
-| | | | | ``MEDIUMTEXT`` [19]_ |
+| | | | | ``MEDIUMTEXT`` [18]_ |
| | | | +----------------------------------------------------------+
-| | | | | ``LONGTEXT`` [20]_ |
+| | | | | ``LONGTEXT`` [19]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | *all* | ``TEXT`` |
| | +--------------------------+ | |
| | | **SQL Anywhere** | | |
-| | +--------------------------+ | |
-| | | **Drizzle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``CLOB`` |
| | +--------------------------+ | |
@@ -773,25 +733,21 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Server** | *all* | ``VARCHAR(MAX)`` |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
-| **json_array** | ``array`` | **MySQL** [1]_ | *all* | ``TINYTEXT`` [17]_ |
+| **json_array** | ``array`` | **MySQL** [1]_ | *all* | ``TINYTEXT`` [16]_ |
| | | | +----------------------------------------------------------+
-| | | | | ``TEXT`` [18]_ |
+| | | | | ``TEXT`` [17]_ |
| | | | +----------------------------------------------------------+
-| | | | | ``MEDIUMTEXT`` [19]_ |
+| | | | | ``MEDIUMTEXT`` [18]_ |
| | | | +----------------------------------------------------------+
-| | | | | ``LONGTEXT`` [20]_ |
+| | | | | ``LONGTEXT`` [19]_ |
| | +--------------------------+---------+----------------------------------------------------------+
-| | | **PostgreSQL** | < 9.2 | ``TEXT`` [1]_ |
-| | | +---------+----------------------------------------------------------+
-| | | | < 9.4 | ``JSON`` |
+| | | **PostgreSQL** | < 9.4 | ``JSON`` |
| | | +---------+----------------------------------------------------------+
-| | | | >= 9.4 | ``JSON`` [21]_ |
+| | | | >= 9.4 | ``JSON`` [20]_ |
| | | | +----------------------------------------------------------+
-| | | | | ``JSONB`` [22]_ |
+| | | | | ``JSONB`` [21]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Anywhere** | *all* | ``TEXT`` [1]_ |
-| | +--------------------------+ | |
-| | | **Drizzle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``CLOB`` [1]_ |
| | +--------------------------+ | |
@@ -799,19 +755,17 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Server** | *all* | ``VARCHAR(MAX)`` [1]_ |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
-| **object** [1]_ | ``object`` | **MySQL** | *all* | ``TINYTEXT`` [17]_ |
+| **object** [1]_ | ``object`` | **MySQL** | *all* | ``TINYTEXT`` [16]_ |
| | | | +----------------------------------------------------------+
-| | | | | ``TEXT`` [18]_ |
+| | | | | ``TEXT`` [17]_ |
| | | | +----------------------------------------------------------+
-| | | | | ``MEDIUMTEXT`` [19]_ |
+| | | | | ``MEDIUMTEXT`` [18]_ |
| | | | +----------------------------------------------------------+
-| | | | | ``LONGTEXT`` [20]_ |
+| | | | | ``LONGTEXT`` [19]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | *all* | ``TEXT`` |
| | +--------------------------+ | |
| | | **SQL Anywhere** | | |
-| | +--------------------------+ | |
-| | | **Drizzle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``CLOB`` |
| | +--------------------------+ | |
@@ -827,10 +781,10 @@ Please also notice the mapping specific footnotes for additional information.
.. [4] Chosen if the column definition has the **fixed** attribute set to ``true``.
.. [5] Silently maps to the vendor specific ``text`` type if the given **length** attribute for
**n** exceeds the maximum length the related platform allows. If this is the case, please
- see [16]_.
+ see [15]_.
.. [6] Silently maps to the vendor specific ``blob`` type if the given **length** attribute for
**n** exceeds the maximum length the related platform allows. If this is the case, please
- see [16]_.
+ see [15]_.
.. [7] **p** is the precision and **s** the scale set in the column definition.
The precision defaults to ``10`` and the scale to ``0`` if not set.
.. [8] Returns PHP ``string`` type value instead of ``integer`` because of maximum integer value
@@ -842,22 +796,20 @@ Please also notice the mapping specific footnotes for additional information.
.. [12] Chosen if the column definition has the **autoincrement** attribute set to ``false`` (default).
.. [13] Chosen if the column definition does not contain the **version** option inside the **platformOptions**
attribute array or is set to ``false`` which marks it as a non-locking information column.
-.. [14] Chosen if the column definition contains the **version** option inside the **platformOptions**
- attribute array and is set to ``true`` which marks it as a locking information column.
-.. [15] Fallback type as the vendor does not support a native date time type with timezone information.
+.. [14] Fallback type as the vendor does not support a native date time type with timezone information.
This means that the timezone information gets lost when storing a value.
-.. [16] Cannot be safely reverse engineered to the same Doctrine type as the vendor does not have a
+.. [15] Cannot be safely reverse engineered to the same Doctrine type as the vendor does not have a
native distinct data type for this mapping. Using this type with this vendor can therefore
have implications on schema comparison (*online* vs *offline* schema) and PHP type safety
(data conversion from database to PHP value) because it silently falls back to its
appropriate Doctrine type.
-.. [17] Chosen if the column length is less or equal to **2 ^ 8 - 1 = 255**.
-.. [18] Chosen if the column length is less or equal to **2 ^ 16 - 1 = 65535**.
-.. [19] Chosen if the column length is less or equal to **2 ^ 24 - 1 = 16777215**.
-.. [20] Chosen if the column length is less or equal to **2 ^ 32 - 1 = 4294967295** or empty.
-.. [21] Chosen if the column definition does not contain the **jsonb** option inside the **platformOptions**
+.. [16] Chosen if the column length is less or equal to **2 ^ 8 - 1 = 255**.
+.. [17] Chosen if the column length is less or equal to **2 ^ 16 - 1 = 65535**.
+.. [18] Chosen if the column length is less or equal to **2 ^ 24 - 1 = 16777215**.
+.. [19] Chosen if the column length is less or equal to **2 ^ 32 - 1 = 4294967295** or empty.
+.. [20] Chosen if the column definition does not contain the **jsonb** option inside the **platformOptions**
attribute array or is set to ``false``.
-.. [22] Chosen if the column definition contains the **jsonb** option inside the **platformOptions**
+.. [21] Chosen if the column definition contains the **jsonb** option inside the **platformOptions**
attribute array and is set to ``true``.
Detection of Database Types
diff --git a/lib/Doctrine/DBAL/Cache/ArrayStatement.php b/lib/Doctrine/DBAL/Cache/ArrayStatement.php
index 6e09e124d83..c7bc6e71d5a 100644
--- a/lib/Doctrine/DBAL/Cache/ArrayStatement.php
+++ b/lib/Doctrine/DBAL/Cache/ArrayStatement.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Cache;
@@ -78,9 +61,9 @@ public function columnCount()
/**
* {@inheritdoc}
*/
- public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
+ public function setFetchMode($fetchMode, ...$args)
{
- if ($arg2 !== null || $arg3 !== null) {
+ if (count($args) > 0) {
throw new \InvalidArgumentException("Caching layer does not support 2nd/3rd argument to setFetchMode()");
}
@@ -102,7 +85,7 @@ public function getIterator()
/**
* {@inheritdoc}
*/
- public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
+ public function fetch($fetchMode = null, ...$args)
{
if (! isset($this->data[$this->num])) {
return false;
@@ -133,10 +116,10 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
/**
* {@inheritdoc}
*/
- public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
+ public function fetchAll($fetchMode = null, ...$args)
{
$rows = [];
- while ($row = $this->fetch($fetchMode)) {
+ while ($row = $this->fetch($fetchMode, ...$args)) {
$rows[] = $row;
}
diff --git a/lib/Doctrine/DBAL/Cache/CacheException.php b/lib/Doctrine/DBAL/Cache/CacheException.php
index 1b69058cde9..00c692940b4 100644
--- a/lib/Doctrine/DBAL/Cache/CacheException.php
+++ b/lib/Doctrine/DBAL/Cache/CacheException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Cache;
diff --git a/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php b/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php
index a722681ce43..3067c1a0766 100644
--- a/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php
+++ b/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Cache;
@@ -97,7 +80,7 @@ public function getCacheKey()
*
* @return array
*/
- public function generateCacheKeys($query, $params, $types, array $connectionParams = [])
+ public function generateCacheKeys(string $query, array $params = [], array $types = [], array $connectionParams = []) : array
{
$realCacheKey = 'query=' . $query .
'¶ms=' . serialize($params) .
diff --git a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
index 4b200a5d438..cd39805a25d 100644
--- a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
+++ b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Cache;
@@ -130,7 +113,7 @@ public function columnCount()
/**
* {@inheritdoc}
*/
- public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
+ public function setFetchMode($fetchMode, ...$args)
{
$this->defaultFetchMode = $fetchMode;
@@ -150,7 +133,7 @@ public function getIterator()
/**
* {@inheritdoc}
*/
- public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
+ public function fetch($fetchMode = null, ...$args)
{
if ($this->data === null) {
$this->data = [];
@@ -190,10 +173,10 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
/**
* {@inheritdoc}
*/
- public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
+ public function fetchAll($fetchMode = null, ...$args)
{
$rows = [];
- while ($row = $this->fetch($fetchMode)) {
+ while ($row = $this->fetch($fetchMode, ...$args)) {
$rows[] = $row;
}
@@ -222,7 +205,7 @@ public function fetchColumn($columnIndex = 0)
*
* @return int The number of rows.
*/
- public function rowCount()
+ public function rowCount() : int
{
return $this->statement->rowCount();
}
diff --git a/lib/Doctrine/DBAL/ColumnCase.php b/lib/Doctrine/DBAL/ColumnCase.php
index 420d868f582..c78ad372e65 100644
--- a/lib/Doctrine/DBAL/ColumnCase.php
+++ b/lib/Doctrine/DBAL/ColumnCase.php
@@ -12,14 +12,14 @@ final class ColumnCase
*
* @see \PDO::CASE_UPPER
*/
- public const UPPER = \PDO::CASE_UPPER;
+ public const UPPER = 1;
/**
* Convert column names to lower case.
*
* @see \PDO::CASE_LOWER
*/
- public const LOWER = \PDO::CASE_LOWER;
+ public const LOWER = 2;
/**
* This class cannot be instantiated.
diff --git a/lib/Doctrine/DBAL/Configuration.php b/lib/Doctrine/DBAL/Configuration.php
index fe9465cdd57..04d58ea95b3 100644
--- a/lib/Doctrine/DBAL/Configuration.php
+++ b/lib/Doctrine/DBAL/Configuration.php
@@ -1,24 +1,8 @@
.
- */
namespace Doctrine\DBAL;
+use Doctrine\DBAL\Logging\NullLogger;
use Doctrine\DBAL\Logging\SQLLogger;
use Doctrine\Common\Cache\Cache;
@@ -43,25 +27,19 @@ class Configuration
protected $_attributes = [];
/**
- * Sets the SQL logger to use. Defaults to NULL which means SQL logging is disabled.
- *
- * @param \Doctrine\DBAL\Logging\SQLLogger|null $logger
- *
- * @return void
+ * Sets the SQL logger to use.
*/
- public function setSQLLogger(SQLLogger $logger = null)
+ public function setSQLLogger(SQLLogger $logger) : void
{
$this->_attributes['sqlLogger'] = $logger;
}
/**
* Gets the SQL logger that is used.
- *
- * @return \Doctrine\DBAL\Logging\SQLLogger|null
*/
- public function getSQLLogger()
+ public function getSQLLogger() : SQLLogger
{
- return $this->_attributes['sqlLogger'] ?? null;
+ return $this->_attributes['sqlLogger'] ?? $this->_attributes['sqlLogger'] = new NullLogger();
}
/**
diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php
index 3c876eb9eb5..da612d485a1 100644
--- a/lib/Doctrine/DBAL/Connection.php
+++ b/lib/Doctrine/DBAL/Connection.php
@@ -1,25 +1,10 @@
.
- */
namespace Doctrine\DBAL;
+use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
+use Doctrine\DBAL\Driver\Statement as DriverStatement;
use Doctrine\DBAL\Exception\InvalidArgumentException;
use Closure;
use Exception;
@@ -34,7 +19,6 @@
use Throwable;
use function array_key_exists;
use function array_merge;
-use function func_get_args;
use function implode;
use function is_int;
use function is_string;
@@ -873,18 +857,16 @@ public function fetchAll($sql, array $params = [], $types = [])
/**
* Prepares an SQL statement.
*
- * @param string $statement The SQL statement to prepare.
+ * @param string $sql The SQL statement to prepare.
*
- * @return \Doctrine\DBAL\Statement The prepared statement.
- *
- * @throws \Doctrine\DBAL\DBALException
+ * @throws DBALException
*/
- public function prepare($statement)
+ public function prepare(string $sql) : DriverStatement
{
try {
- $stmt = new Statement($statement, $this);
+ $stmt = new Statement($sql, $this);
} catch (Exception $ex) {
- throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $statement);
+ throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $sql);
}
$stmt->setFetchMode($this->defaultFetchMode);
@@ -898,16 +880,14 @@ public function prepare($statement)
* If the query is parametrized, a prepared statement is used.
* If an SQLLogger is configured, the execution is logged.
*
- * @param string $query The SQL query to execute.
- * @param array $params The parameters to bind to the query, if any.
- * @param array $types The types the previous parameters are in.
- * @param \Doctrine\DBAL\Cache\QueryCacheProfile|null $qcp The query cache profile, optional.
- *
- * @return \Doctrine\DBAL\Driver\Statement The executed statement.
+ * @param string $query The SQL query to execute.
+ * @param mixed[] $params The parameters to bind to the query, if any.
+ * @param (int|string|Type)[] $types The types the previous parameters are in.
+ * @param QueryCacheProfile|null $qcp The query cache profile, optional.
*
- * @throws \Doctrine\DBAL\DBALException
+ * @throws DBALException
*/
- public function executeQuery($query, array $params = [], $types = [], QueryCacheProfile $qcp = null)
+ public function executeQuery(string $query, array $params = [], array $types = [], ?QueryCacheProfile $qcp = null) : ResultStatement
{
if ($qcp !== null) {
return $this->executeCacheQuery($query, $params, $types, $qcp);
@@ -916,9 +896,7 @@ public function executeQuery($query, array $params = [], $types = [], QueryCache
$this->connect();
$logger = $this->_config->getSQLLogger();
- if ($logger) {
- $logger->startQuery($query, $params, $types);
- }
+ $logger->startQuery($query, $params, $types);
try {
if ($params) {
@@ -940,9 +918,7 @@ public function executeQuery($query, array $params = [], $types = [], QueryCache
$stmt->setFetchMode($this->defaultFetchMode);
- if ($logger) {
- $logger->stopQuery();
- }
+ $logger->stopQuery();
return $stmt;
}
@@ -950,16 +926,14 @@ public function executeQuery($query, array $params = [], $types = [], QueryCache
/**
* Executes a caching query.
*
- * @param string $query The SQL query to execute.
- * @param array $params The parameters to bind to the query, if any.
- * @param array $types The types the previous parameters are in.
- * @param \Doctrine\DBAL\Cache\QueryCacheProfile $qcp The query cache profile.
+ * @param string $query The SQL query to execute.
+ * @param mixed[] $params The parameters to bind to the query, if any.
+ * @param (int|string)|Type[] $types The types the previous parameters are in.
+ * @param QueryCacheProfile $qcp The query cache profile.
*
- * @return \Doctrine\DBAL\Driver\ResultStatement
- *
- * @throws \Doctrine\DBAL\Cache\CacheException
+ * @throws DBALException
*/
- public function executeCacheQuery($query, $params, $types, QueryCacheProfile $qcp)
+ public function executeCacheQuery(string $query, array $params, array $types, QueryCacheProfile $qcp) : ResultStatement
{
$resultCache = $qcp->getResultCacheDriver() ?: $this->_config->getResultCacheImpl();
if ( ! $resultCache) {
@@ -1014,34 +988,24 @@ public function project($query, array $params, Closure $function)
}
/**
- * Executes an SQL statement, returning a result set as a Statement object.
- *
- * @return \Doctrine\DBAL\Driver\Statement
- *
- * @throws \Doctrine\DBAL\DBALException
+ * {@inheritDoc}
*/
- public function query()
+ public function query(string $sql) : ResultStatement
{
$this->connect();
- $args = func_get_args();
-
$logger = $this->_config->getSQLLogger();
- if ($logger) {
- $logger->startQuery($args[0]);
- }
+ $logger->startQuery($sql);
try {
- $statement = $this->_conn->query(...$args);
+ $statement = $this->_conn->query($sql);
} catch (Exception $ex) {
- throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $args[0]);
+ throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $sql);
}
$statement->setFetchMode($this->defaultFetchMode);
- if ($logger) {
- $logger->stopQuery();
- }
+ $logger->stopQuery();
return $statement;
}
@@ -1052,22 +1016,18 @@ public function query()
*
* This method supports PDO binding types as well as DBAL mapping types.
*
- * @param string $query The SQL query.
- * @param array $params The query parameters.
- * @param array $types The parameter types.
+ * @param string $query The SQL query.
+ * @param mixed[] $params The query parameters.
+ * @param (int|string|Type)[] $types The parameter types.
*
- * @return int The number of affected rows.
- *
- * @throws \Doctrine\DBAL\DBALException
+ * @throws DBALException
*/
- public function executeUpdate($query, array $params = [], array $types = [])
+ public function executeUpdate(string $query, array $params = [], array $types = []) : int
{
$this->connect();
$logger = $this->_config->getSQLLogger();
- if ($logger) {
- $logger->startQuery($query, $params, $types);
- }
+ $logger->startQuery($query, $params, $types);
try {
if ($params) {
@@ -1088,30 +1048,20 @@ public function executeUpdate($query, array $params = [], array $types = [])
throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $query, $this->resolveParams($params, $types));
}
- if ($logger) {
- $logger->stopQuery();
- }
+ $logger->stopQuery();
return $result;
}
/**
- * Executes an SQL statement and return the number of affected rows.
- *
- * @param string $statement
- *
- * @return int The number of affected rows.
- *
- * @throws \Doctrine\DBAL\DBALException
+ * {@inheritDoc}
*/
- public function exec($statement)
+ public function exec(string $statement) : int
{
$this->connect();
$logger = $this->_config->getSQLLogger();
- if ($logger) {
- $logger->startQuery($statement);
- }
+ $logger->startQuery($statement);
try {
$result = $this->_conn->exec($statement);
@@ -1119,9 +1069,7 @@ public function exec($statement)
throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $statement);
}
- if ($logger) {
- $logger->stopQuery();
- }
+ $logger->stopQuery();
return $result;
}
@@ -1191,7 +1139,6 @@ public function lastInsertId($seqName = null)
*
* @return mixed The value returned by $func
*
- * @throws Exception
* @throws Throwable
*/
public function transactional(Closure $func)
@@ -1201,9 +1148,6 @@ public function transactional(Closure $func)
$res = $func($this);
$this->commit();
return $res;
- } catch (Exception $e) {
- $this->rollBack();
- throw $e;
} catch (Throwable $e) {
$this->rollBack();
throw $e;
@@ -1267,21 +1211,13 @@ public function beginTransaction()
$logger = $this->_config->getSQLLogger();
if ($this->_transactionNestingLevel == 1) {
- if ($logger) {
- $logger->startQuery('"START TRANSACTION"');
- }
+ $logger->startQuery('"START TRANSACTION"');
$this->_conn->beginTransaction();
- if ($logger) {
- $logger->stopQuery();
- }
+ $logger->stopQuery();
} elseif ($this->_nestTransactionsWithSavepoints) {
- if ($logger) {
- $logger->startQuery('"SAVEPOINT"');
- }
+ $logger->startQuery('"SAVEPOINT"');
$this->createSavepoint($this->_getNestedTransactionSavePointName());
- if ($logger) {
- $logger->stopQuery();
- }
+ $logger->stopQuery();
}
}
@@ -1307,21 +1243,13 @@ public function commit()
$logger = $this->_config->getSQLLogger();
if ($this->_transactionNestingLevel == 1) {
- if ($logger) {
- $logger->startQuery('"COMMIT"');
- }
+ $logger->startQuery('"COMMIT"');
$this->_conn->commit();
- if ($logger) {
- $logger->stopQuery();
- }
+ $logger->stopQuery();
} elseif ($this->_nestTransactionsWithSavepoints) {
- if ($logger) {
- $logger->startQuery('"RELEASE SAVEPOINT"');
- }
+ $logger->startQuery('"RELEASE SAVEPOINT"');
$this->releaseSavepoint($this->_getNestedTransactionSavePointName());
- if ($logger) {
- $logger->stopQuery();
- }
+ $logger->stopQuery();
}
--$this->_transactionNestingLevel;
@@ -1365,28 +1293,20 @@ public function rollBack()
$logger = $this->_config->getSQLLogger();
if ($this->_transactionNestingLevel == 1) {
- if ($logger) {
- $logger->startQuery('"ROLLBACK"');
- }
+ $logger->startQuery('"ROLLBACK"');
$this->_transactionNestingLevel = 0;
$this->_conn->rollBack();
$this->_isRollbackOnly = false;
- if ($logger) {
- $logger->stopQuery();
- }
+ $logger->stopQuery();
if (false === $this->autoCommit) {
$this->beginTransaction();
}
} elseif ($this->_nestTransactionsWithSavepoints) {
- if ($logger) {
- $logger->startQuery('"ROLLBACK TO SAVEPOINT"');
- }
+ $logger->startQuery('"ROLLBACK TO SAVEPOINT"');
$this->rollbackSavepoint($this->_getNestedTransactionSavePointName());
--$this->_transactionNestingLevel;
- if ($logger) {
- $logger->stopQuery();
- }
+ $logger->stopQuery();
} else {
$this->_isRollbackOnly = true;
--$this->_transactionNestingLevel;
@@ -1540,16 +1460,11 @@ public function convertToPHPValue($value, $type)
* Binds a set of parameters, some or all of which are typed with a PDO binding type
* or DBAL mapping type, to a given statement.
*
- * @param \Doctrine\DBAL\Driver\Statement $stmt The statement to bind the values to.
- * @param array $params The map/list of named/positional parameters.
- * @param array $types The parameter types (PDO binding types or DBAL mapping types).
- *
- * @return void
- *
- * @internal Duck-typing used on the $stmt parameter to support driver statements as well as
- * raw PDOStatement instances.
+ * @param DriverStatement $stmt The statement to bind the values to.
+ * @param mixed[] $params The map/list of named/positional parameters.
+ * @param (int|string|Type)[] $types The parameter types.
*/
- private function _bindTypedValues($stmt, array $params, array $types)
+ private function _bindTypedValues(DriverStatement $stmt, array $params, array $types) : void
{
// Check whether parameters are positional or named. Mixing is not allowed, just like in PDO.
if (is_int(key($params))) {
diff --git a/lib/Doctrine/DBAL/ConnectionException.php b/lib/Doctrine/DBAL/ConnectionException.php
index 86494b0361a..db94489668a 100644
--- a/lib/Doctrine/DBAL/ConnectionException.php
+++ b/lib/Doctrine/DBAL/ConnectionException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL;
diff --git a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php
index e769cc4299e..fe5e5516efa 100644
--- a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php
+++ b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php
@@ -1,33 +1,17 @@
.
- */
namespace Doctrine\DBAL\Connections;
+use Doctrine\Common\EventManager;
+use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
-use Doctrine\DBAL\Configuration;
-use Doctrine\Common\EventManager;
+use Doctrine\DBAL\Driver\ResultStatement;
+use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Events;
use function array_rand;
use function count;
-use function func_get_args;
/**
* Master-Slave Connection
@@ -103,10 +87,7 @@ class MasterSlaveConnection extends Connection
/**
* Creates Master Slave Connection.
*
- * @param array $params
- * @param \Doctrine\DBAL\Driver $driver
- * @param \Doctrine\DBAL\Configuration|null $config
- * @param \Doctrine\Common\EventManager|null $eventManager
+ * @param mixed[] $params
*
* @throws \InvalidArgumentException
*/
@@ -239,7 +220,7 @@ protected function chooseConnectionConfiguration($connectionName, $params)
/**
* {@inheritDoc}
*/
- public function executeUpdate($query, array $params = [], array $types = [])
+ public function executeUpdate(string $query, array $params = [], array $types = []) : int
{
$this->connect('master');
@@ -322,7 +303,7 @@ public function insert($tableName, array $data, array $types = [])
/**
* {@inheritDoc}
*/
- public function exec($statement)
+ public function exec(string $statement) : int
{
$this->connect('master');
@@ -362,22 +343,16 @@ public function rollbackSavepoint($savepoint)
/**
* {@inheritDoc}
*/
- public function query()
+ public function query(string $sql) : ResultStatement
{
$this->connect('master');
- $args = func_get_args();
-
$logger = $this->getConfiguration()->getSQLLogger();
- if ($logger) {
- $logger->startQuery($args[0]);
- }
+ $logger->startQuery($sql);
- $statement = $this->_conn->query(...$args);
+ $statement = $this->_conn->query($sql);
- if ($logger) {
- $logger->stopQuery();
- }
+ $logger->stopQuery();
return $statement;
}
@@ -385,10 +360,10 @@ public function query()
/**
* {@inheritDoc}
*/
- public function prepare($statement)
+ public function prepare(string $sql) : Statement
{
$this->connect('master');
- return parent::prepare($statement);
+ return parent::prepare($sql);
}
}
diff --git a/lib/Doctrine/DBAL/DBALException.php b/lib/Doctrine/DBAL/DBALException.php
index 67265d954fb..72413141e4a 100644
--- a/lib/Doctrine/DBAL/DBALException.php
+++ b/lib/Doctrine/DBAL/DBALException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL;
diff --git a/lib/Doctrine/DBAL/Driver.php b/lib/Doctrine/DBAL/Driver.php
index 300a27dec5b..9bd58e80070 100644
--- a/lib/Doctrine/DBAL/Driver.php
+++ b/lib/Doctrine/DBAL/Driver.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL;
diff --git a/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php b/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php
index baa081690c0..ad157f03830 100644
--- a/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php
+++ b/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver;
diff --git a/lib/Doctrine/DBAL/Driver/AbstractDriverException.php b/lib/Doctrine/DBAL/Driver/AbstractDriverException.php
index 83c38d71db6..d34ca5cdd93 100644
--- a/lib/Doctrine/DBAL/Driver/AbstractDriverException.php
+++ b/lib/Doctrine/DBAL/Driver/AbstractDriverException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver;
diff --git a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php
index ed881052c0b..abe014b0c2f 100644
--- a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php
+++ b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver;
diff --git a/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php b/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php
index 26cfcd1500c..d9a92a0f428 100644
--- a/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php
+++ b/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver;
diff --git a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php
index ea7aa71676b..7a9ad136053 100644
--- a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php
+++ b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver;
@@ -23,8 +6,6 @@
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\PostgreSQL100Platform;
-use Doctrine\DBAL\Platforms\PostgreSQL91Platform;
-use Doctrine\DBAL\Platforms\PostgreSQL92Platform;
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Schema\PostgreSqlSchemaManager;
@@ -121,10 +102,6 @@ public function createDatabasePlatformForVersion($version)
return new PostgreSQL100Platform();
case version_compare($version, '9.4', '>='):
return new PostgreSQL94Platform();
- case version_compare($version, '9.2', '>='):
- return new PostgreSQL92Platform();
- case version_compare($version, '9.1', '>='):
- return new PostgreSQL91Platform();
default:
return new PostgreSqlPlatform();
}
diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php
index ca966511d3b..b1546126da8 100644
--- a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php
+++ b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php
@@ -1,30 +1,10 @@
.
- */
namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Exception;
-use Doctrine\DBAL\Platforms\SQLAnywhere11Platform;
-use Doctrine\DBAL\Platforms\SQLAnywhere12Platform;
-use Doctrine\DBAL\Platforms\SQLAnywhere16Platform;
use Doctrine\DBAL\Platforms\SQLAnywherePlatform;
use Doctrine\DBAL\Schema\SQLAnywhereSchemaManager;
use Doctrine\DBAL\VersionAwarePlatformDriver;
@@ -108,12 +88,6 @@ public function createDatabasePlatformForVersion($version)
$version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion . '.' . $buildVersion;
switch(true) {
- case version_compare($version, '16', '>='):
- return new SQLAnywhere16Platform();
- case version_compare($version, '12', '>='):
- return new SQLAnywhere12Platform();
- case version_compare($version, '11', '>='):
- return new SQLAnywhere11Platform();
default:
return new SQLAnywherePlatform();
}
@@ -134,7 +108,7 @@ public function getDatabase(\Doctrine\DBAL\Connection $conn)
*/
public function getDatabasePlatform()
{
- return new SQLAnywhere12Platform();
+ return new SQLAnywherePlatform();
}
/**
diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php
index fb9c989bd14..94b0e5fdf1f 100644
--- a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php
+++ b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php
@@ -1,28 +1,9 @@
.
- */
namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver;
-use Doctrine\DBAL\Platforms\SQLServer2005Platform;
-use Doctrine\DBAL\Platforms\SQLServer2008Platform;
use Doctrine\DBAL\Platforms\SQLServer2012Platform;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Schema\SQLServerSchemaManager;
@@ -64,10 +45,6 @@ public function createDatabasePlatformForVersion($version)
switch(true) {
case version_compare($version, '11.00.2100', '>='):
return new SQLServer2012Platform();
- case version_compare($version, '10.00.1600', '>='):
- return new SQLServer2008Platform();
- case version_compare($version, '9.00.1399', '>='):
- return new SQLServer2005Platform();
default:
return new SQLServerPlatform();
}
@@ -88,7 +65,7 @@ public function getDatabase(\Doctrine\DBAL\Connection $conn)
*/
public function getDatabasePlatform()
{
- return new SQLServer2008Platform();
+ return new SQLServerPlatform();
}
/**
diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php
index 406cb92ef2f..f8eb73af238 100644
--- a/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php
+++ b/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver;
diff --git a/lib/Doctrine/DBAL/Driver/Connection.php b/lib/Doctrine/DBAL/Driver/Connection.php
index 773407510a6..4c133369988 100644
--- a/lib/Doctrine/DBAL/Driver/Connection.php
+++ b/lib/Doctrine/DBAL/Driver/Connection.php
@@ -1,24 +1,8 @@
.
- */
namespace Doctrine\DBAL\Driver;
+use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\ParameterType;
/**
@@ -33,19 +17,15 @@ interface Connection
{
/**
* Prepares a statement for execution and returns a Statement object.
- *
- * @param string $prepareString
- *
- * @return \Doctrine\DBAL\Driver\Statement
*/
- public function prepare($prepareString);
+ public function prepare(string $sql) : Statement;
/**
* Executes an SQL statement, returning a result set as a Statement object.
*
- * @return \Doctrine\DBAL\Driver\Statement
+ * @throws DBALException
*/
- public function query();
+ public function query(string $sql) : ResultStatement;
/**
* Quotes a string for use in a query.
@@ -60,11 +40,9 @@ public function quote($input, $type = ParameterType::STRING);
/**
* Executes an SQL statement and return the number of affected rows.
*
- * @param string $statement
- *
- * @return int
+ * @throws DBALException
*/
- public function exec($statement);
+ public function exec(string $statement) : int;
/**
* Returns the ID of the last inserted row or sequence value.
diff --git a/lib/Doctrine/DBAL/Driver/DriverException.php b/lib/Doctrine/DBAL/Driver/DriverException.php
index ce1d1e38149..c020c295169 100644
--- a/lib/Doctrine/DBAL/Driver/DriverException.php
+++ b/lib/Doctrine/DBAL/Driver/DriverException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver;
diff --git a/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Connection.php b/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Connection.php
deleted file mode 100644
index bfc61acf9b8..00000000000
--- a/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Connection.php
+++ /dev/null
@@ -1,40 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Driver\DrizzlePDOMySql;
-
-use Doctrine\DBAL\ParameterType;
-
-/**
- * @author Kim Hemsø Rasmussen
- */
-class Connection extends \Doctrine\DBAL\Driver\PDOConnection
-{
- /**
- * {@inheritdoc}
- */
- public function quote($value, $type = ParameterType::STRING)
- {
- if ($type === ParameterType::BOOLEAN) {
- return $value ? 'true' : 'false';
- }
-
- return parent::quote($value, $type);
- }
-}
diff --git a/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php b/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php
deleted file mode 100644
index 547fdb79570..00000000000
--- a/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php
+++ /dev/null
@@ -1,78 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Driver\DrizzlePDOMySql;
-
-use Doctrine\DBAL\Platforms\DrizzlePlatform;
-use Doctrine\DBAL\Schema\DrizzleSchemaManager;
-
-/**
- * Drizzle driver using PDO MySql.
- *
- * @author Kim Hemsø Rasmussen
- */
-class Driver extends \Doctrine\DBAL\Driver\PDOMySql\Driver
-{
- /**
- * {@inheritdoc}
- */
- public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
- {
- $conn = new Connection(
- $this->constructPdoDsn($params),
- $username,
- $password,
- $driverOptions
- );
-
- return $conn;
- }
-
- /**
- * {@inheritdoc}
- */
- public function createDatabasePlatformForVersion($version)
- {
- return $this->getDatabasePlatform();
- }
-
- /**
- * {@inheritdoc}
- */
- public function getDatabasePlatform()
- {
- return new DrizzlePlatform();
- }
-
- /**
- * {@inheritdoc}
- */
- public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
- {
- return new DrizzleSchemaManager($conn);
- }
-
- /**
- * {@inheritdoc}
- */
- public function getName()
- {
- return 'drizzle_pdo_mysql';
- }
-}
diff --git a/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php b/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php
index 0bd8d516e14..77264e6e9f1 100644
--- a/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php
+++ b/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver;
diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php
index 72ef796862d..e122748dc50 100644
--- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php
+++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php
@@ -1,26 +1,11 @@
.
- */
namespace Doctrine\DBAL\Driver\IBMDB2;
use Doctrine\DBAL\Driver\Connection;
+use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
+use Doctrine\DBAL\Driver\Statement as DriverStatement;
use Doctrine\DBAL\ParameterType;
use const DB2_AUTOCOMMIT_OFF;
use const DB2_AUTOCOMMIT_ON;
@@ -38,7 +23,6 @@
use function db2_rollback;
use function db2_server_info;
use function db2_stmt_errormsg;
-use function func_get_args;
class DB2Connection implements Connection, ServerInfoAwareConnection
{
@@ -90,7 +74,7 @@ public function requiresQueryForServerVersion()
/**
* {@inheritdoc}
*/
- public function prepare($sql)
+ public function prepare(string $sql) : DriverStatement
{
$stmt = @db2_prepare($this->_conn, $sql);
if ( ! $stmt) {
@@ -103,10 +87,8 @@ public function prepare($sql)
/**
* {@inheritdoc}
*/
- public function query()
+ public function query(string $sql) : ResultStatement
{
- $args = func_get_args();
- $sql = $args[0];
$stmt = $this->prepare($sql);
$stmt->execute();
@@ -130,7 +112,7 @@ public function quote($input, $type = ParameterType::STRING)
/**
* {@inheritdoc}
*/
- public function exec($statement)
+ public function exec(string $statement) : int
{
$stmt = @db2_exec($this->_conn, $statement);
diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php
index de5921edd23..247247ec151 100644
--- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php
+++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\IBMDB2;
diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Exception.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Exception.php
index 72775cbfe70..1381904cf10 100644
--- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Exception.php
+++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Exception.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\IBMDB2;
diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
index 4aaa054abf7..231a5609895 100644
--- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
+++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\IBMDB2;
@@ -39,8 +22,6 @@
use function db2_num_rows;
use function db2_stmt_error;
use function db2_stmt_errormsg;
-use function func_get_args;
-use function func_num_args;
use function gettype;
use function is_object;
use function is_string;
@@ -212,11 +193,17 @@ public function execute($params = null)
/**
* {@inheritdoc}
*/
- public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
+ public function setFetchMode($fetchMode, ...$args)
{
- $this->_defaultFetchMode = $fetchMode;
- $this->defaultFetchClass = $arg2 ? $arg2 : $this->defaultFetchClass;
- $this->defaultFetchClassCtorArgs = $arg3 ? (array) $arg3 : $this->defaultFetchClassCtorArgs;
+ $this->_defaultFetchMode = $fetchMode;
+
+ if (isset($args[0])) {
+ $this->defaultFetchClass = $args[0];
+ }
+
+ if (isset($args[1])) {
+ $this->defaultFetchClassCtorArgs = (array) $args[2];
+ }
return true;
}
@@ -232,7 +219,7 @@ public function getIterator()
/**
* {@inheritdoc}
*/
- public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
+ public function fetch($fetchMode = null, ...$args)
{
// do not try fetching from the statement if it's not expected to contain result
// in order to prevent exceptional situation
@@ -255,10 +242,9 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
$className = $this->defaultFetchClass;
$ctorArgs = $this->defaultFetchClassCtorArgs;
- if (func_num_args() >= 2) {
- $args = func_get_args();
- $className = $args[1];
- $ctorArgs = $args[2] ?? [];
+ if (count($args) > 0) {
+ $className = $args[0];
+ $ctorArgs = $args[1] ?? [];
}
$result = db2_fetch_object($this->_stmt);
@@ -283,23 +269,23 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
/**
* {@inheritdoc}
*/
- public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
+ public function fetchAll($fetchMode = null, ...$args)
{
$rows = [];
switch ($fetchMode) {
case FetchMode::CUSTOM_OBJECT:
- while ($row = call_user_func_array([$this, 'fetch'], func_get_args())) {
+ while (($row = $this->fetch($fetchMode, ...$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;
}
}
@@ -324,7 +310,7 @@ public function fetchColumn($columnIndex = 0)
/**
* {@inheritdoc}
*/
- public function rowCount()
+ public function rowCount() : int
{
return (@db2_num_rows($this->_stmt)) ? : 0;
}
diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php b/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php
index d04e194d14f..1eb6bdad525 100644
--- a/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php
+++ b/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\Mysqli;
diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php
index 98a5b2361c6..2383483a876 100644
--- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php
+++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php
@@ -1,31 +1,15 @@
.
- */
namespace Doctrine\DBAL\Driver\Mysqli;
-use Doctrine\DBAL\Driver\Connection as Connection;
+use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\PingableConnection;
+use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
+use Doctrine\DBAL\Driver\Statement as DriverStatement;
use Doctrine\DBAL\ParameterType;
use function defined;
use function floor;
-use function func_get_args;
use function in_array;
use function ini_get;
use function mysqli_errno;
@@ -138,18 +122,16 @@ public function requiresQueryForServerVersion()
/**
* {@inheritdoc}
*/
- public function prepare($prepareString)
+ public function prepare(string $sql) : DriverStatement
{
- return new MysqliStatement($this->_conn, $prepareString);
+ return new MysqliStatement($this->_conn, $sql);
}
/**
* {@inheritdoc}
*/
- public function query()
+ public function query(string $sql) : ResultStatement
{
- $args = func_get_args();
- $sql = $args[0];
$stmt = $this->prepare($sql);
$stmt->execute();
@@ -167,7 +149,7 @@ public function quote($input, $type = ParameterType::STRING)
/**
* {@inheritdoc}
*/
- public function exec($statement)
+ public function exec(string $statement) : int
{
if (false === $this->_conn->query($statement)) {
throw new MysqliException($this->_conn->error, $this->_conn->sqlstate, $this->_conn->errno);
diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php
index 23728b113a6..c13b8eaadcf 100644
--- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php
+++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\Mysqli;
diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
index db78c7178ef..dd87d3207ed 100644
--- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
+++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\Mysqli;
@@ -272,7 +255,7 @@ private function _fetch()
/**
* {@inheritdoc}
*/
- public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
+ public function fetch($fetchMode = null, ...$args)
{
// do not try fetching from the statement if it's not expected to contain result
// in order to prevent exceptional situation
@@ -326,7 +309,7 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
/**
* {@inheritdoc}
*/
- public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
+ public function fetchAll($fetchMode = null, ...$args)
{
$fetchMode = $fetchMode ?: $this->_defaultFetchMode;
@@ -389,7 +372,7 @@ public function closeCursor()
/**
* {@inheritdoc}
*/
- public function rowCount()
+ public function rowCount() : int
{
if (false === $this->_columnNames) {
return $this->_stmt->affected_rows;
@@ -409,7 +392,7 @@ public function columnCount()
/**
* {@inheritdoc}
*/
- public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
+ public function setFetchMode($fetchMode, ...$args)
{
$this->_defaultFetchMode = $fetchMode;
diff --git a/lib/Doctrine/DBAL/Driver/OCI8/Driver.php b/lib/Doctrine/DBAL/Driver/OCI8/Driver.php
index 925e9b70f78..216eddb6bcb 100644
--- a/lib/Doctrine/DBAL/Driver/OCI8/Driver.php
+++ b/lib/Doctrine/DBAL/Driver/OCI8/Driver.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\OCI8;
diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php
index e2111d47444..07cf3070795 100644
--- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php
+++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php
@@ -1,26 +1,11 @@
.
- */
namespace Doctrine\DBAL\Driver\OCI8;
use Doctrine\DBAL\Driver\Connection;
+use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
+use Doctrine\DBAL\Driver\Statement as DriverStatement;
use Doctrine\DBAL\ParameterType;
use const OCI_COMMIT_ON_SUCCESS;
use const OCI_DEFAULT;
@@ -28,7 +13,6 @@
use function addcslashes;
use function define;
use function defined;
-use function func_get_args;
use function is_float;
use function is_int;
use function oci_commit;
@@ -117,19 +101,16 @@ public function requiresQueryForServerVersion()
/**
* {@inheritdoc}
*/
- public function prepare($prepareString)
+ public function prepare(string $sql) : DriverStatement
{
- return new OCI8Statement($this->dbh, $prepareString, $this);
+ return new OCI8Statement($this->dbh, $sql, $this);
}
/**
* {@inheritdoc}
*/
- public function query()
+ public function query(string $sql) : ResultStatement
{
- $args = func_get_args();
- $sql = $args[0];
- //$fetchMode = $args[1];
$stmt = $this->prepare($sql);
$stmt->execute();
@@ -152,7 +133,7 @@ public function quote($value, $type = ParameterType::STRING)
/**
* {@inheritdoc}
*/
- public function exec($statement)
+ public function exec(string $statement) : int
{
$stmt = $this->prepare($statement);
$stmt->execute();
diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php
index 1cd08b8a408..51e52a51516 100644
--- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php
+++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\OCI8;
diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
index 1d771007fda..a70da6fb94b 100644
--- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
+++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\OCI8;
@@ -390,7 +373,7 @@ public function execute($params = null)
/**
* {@inheritdoc}
*/
- public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
+ public function setFetchMode($fetchMode, ...$args)
{
$this->_defaultFetchMode = $fetchMode;
@@ -408,7 +391,7 @@ public function getIterator()
/**
* {@inheritdoc}
*/
- public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
+ public function fetch($fetchMode = null, ...$args)
{
// do not try fetching from the statement if it's not expected to contain result
// in order to prevent exceptional situation
@@ -439,7 +422,7 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
/**
* {@inheritdoc}
*/
- public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
+ public function fetchAll($fetchMode = null, ...$args)
{
$fetchMode = $fetchMode ?: $this->_defaultFetchMode;
@@ -508,7 +491,7 @@ public function fetchColumn($columnIndex = 0)
/**
* {@inheritdoc}
*/
- public function rowCount()
+ public function rowCount() : int
{
return oci_num_rows($this->_sth);
}
diff --git a/lib/Doctrine/DBAL/Driver/PDOConnection.php b/lib/Doctrine/DBAL/Driver/PDOConnection.php
index 62a214a53d2..ea66dd3649d 100644
--- a/lib/Doctrine/DBAL/Driver/PDOConnection.php
+++ b/lib/Doctrine/DBAL/Driver/PDOConnection.php
@@ -1,37 +1,20 @@
.
- */
namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\ParameterType;
use PDO;
-use function count;
-use function func_get_args;
/**
* PDO implementation of the Connection interface.
- * Used by all PDO-based drivers.
*
- * @since 2.0
+ * Used by all PDO-based drivers.
*/
-class PDOConnection extends PDO implements Connection, ServerInfoAwareConnection
+class PDOConnection implements Connection, ServerInfoAwareConnection
{
+ /** @var PDO */
+ private $connection;
+
/**
* @param string $dsn
* @param string|null $user
@@ -43,9 +26,8 @@ class PDOConnection extends PDO implements Connection, ServerInfoAwareConnection
public function __construct($dsn, $user = null, $password = null, array $options = null)
{
try {
- parent::__construct($dsn, $user, $password, $options);
- $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, ['Doctrine\DBAL\Driver\PDOStatement', []]);
- $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ $this->connection = new PDO($dsn, $user, $password, $options);
+ $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (\PDOException $exception) {
throw new PDOException($exception);
}
@@ -54,10 +36,10 @@ public function __construct($dsn, $user = null, $password = null, array $options
/**
* {@inheritdoc}
*/
- public function exec($statement)
+ public function exec(string $statement) : int
{
try {
- return parent::exec($statement);
+ return $this->connection->exec($statement);
} catch (\PDOException $exception) {
throw new PDOException($exception);
}
@@ -68,16 +50,18 @@ public function exec($statement)
*/
public function getServerVersion()
{
- return PDO::getAttribute(PDO::ATTR_SERVER_VERSION);
+ return $this->connection->getAttribute(PDO::ATTR_SERVER_VERSION);
}
/**
* {@inheritdoc}
*/
- public function prepare($prepareString, $driverOptions = [])
+ public function prepare(string $sql) : Statement
{
try {
- return parent::prepare($prepareString, $driverOptions);
+ return $this->createStatement(
+ $this->connection->prepare($sql)
+ );
} catch (\PDOException $exception) {
throw new PDOException($exception);
}
@@ -86,25 +70,12 @@ public function prepare($prepareString, $driverOptions = [])
/**
* {@inheritdoc}
*/
- public function query()
+ public function query(string $sql) : ResultStatement
{
- $args = func_get_args();
- $argsCount = count($args);
-
try {
- if ($argsCount == 4) {
- return parent::query($args[0], $args[1], $args[2], $args[3]);
- }
-
- if ($argsCount == 3) {
- return parent::query($args[0], $args[1], $args[2]);
- }
-
- if ($argsCount == 2) {
- return parent::query($args[0], $args[1]);
- }
-
- return parent::query($args[0]);
+ return $this->createStatement(
+ $this->connection->query($sql)
+ );
} catch (\PDOException $exception) {
throw new PDOException($exception);
}
@@ -115,7 +86,7 @@ public function query()
*/
public function quote($input, $type = ParameterType::STRING)
{
- return parent::quote($input, $type);
+ return $this->connection->quote($input, $type);
}
/**
@@ -123,7 +94,7 @@ public function quote($input, $type = ParameterType::STRING)
*/
public function lastInsertId($name = null)
{
- return parent::lastInsertId($name);
+ return $this->connection->lastInsertId($name);
}
/**
@@ -133,4 +104,60 @@ public function requiresQueryForServerVersion()
{
return false;
}
+
+ /**
+ * Creates a wrapped statement
+ *
+ * @param \PDOStatement $stmt
+ * @return PDOStatement
+ */
+ protected function createStatement(\PDOStatement $stmt) : PDOStatement
+ {
+ return new PDOStatement($stmt);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function beginTransaction()
+ {
+ return $this->connection->beginTransaction();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function commit()
+ {
+ return $this->connection->commit();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function rollBack()
+ {
+ return $this->connection->rollBack();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function errorCode()
+ {
+ return $this->connection->errorCode();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function errorInfo()
+ {
+ return $this->connection->errorInfo();
+ }
+
+ public function getWrappedConnection() : PDO
+ {
+ return $this->connection;
+ }
}
diff --git a/lib/Doctrine/DBAL/Driver/PDOException.php b/lib/Doctrine/DBAL/Driver/PDOException.php
index 25689b66e2c..6104155bbb5 100644
--- a/lib/Doctrine/DBAL/Driver/PDOException.php
+++ b/lib/Doctrine/DBAL/Driver/PDOException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver;
diff --git a/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php b/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php
deleted file mode 100644
index faebcd84268..00000000000
--- a/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php
+++ /dev/null
@@ -1,83 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Driver\PDOIbm;
-
-use Doctrine\DBAL\Driver\AbstractDB2Driver;
-use Doctrine\DBAL\Driver\PDOConnection;
-
-/**
- * Driver for the PDO IBM extension.
- *
- * @link www.doctrine-project.org
- * @since 1.0
- * @author Benjamin Eberlei
- * @author Guilherme Blanco
- * @author Jonathan Wage
- * @author Roman Borschel
- */
-class Driver extends AbstractDB2Driver
-{
- /**
- * {@inheritdoc}
- */
- public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
- {
- $conn = new PDOConnection(
- $this->_constructPdoDsn($params),
- $username,
- $password,
- $driverOptions
- );
-
- return $conn;
- }
-
- /**
- * Constructs the IBM PDO DSN.
- *
- * @param array $params
- *
- * @return string The DSN.
- */
- private function _constructPdoDsn(array $params)
- {
- $dsn = 'ibm:';
- if (isset($params['host'])) {
- $dsn .= 'HOSTNAME=' . $params['host'] . ';';
- }
- if (isset($params['port'])) {
- $dsn .= 'PORT=' . $params['port'] . ';';
- }
- $dsn .= 'PROTOCOL=TCPIP;';
- if (isset($params['dbname'])) {
- $dsn .= 'DATABASE=' . $params['dbname'] . ';';
- }
-
- return $dsn;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getName()
- {
- return 'pdo_ibm';
- }
-}
diff --git a/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php b/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php
index 44a9d5b82f6..bcf3b5b47f6 100644
--- a/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php
+++ b/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\PDOMySql;
diff --git a/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php b/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php
index 61edca747e9..484962f8afc 100644
--- a/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php
+++ b/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\PDOOracle;
diff --git a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php
index 685e8d77750..5b6d0b0288f 100644
--- a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php
+++ b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\PDOPgSql;
@@ -39,7 +22,7 @@ class Driver extends AbstractPostgreSQLDriver
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{
try {
- $pdo = new PDOConnection(
+ $connection = new PDOConnection(
$this->_constructPdoDsn($params),
$username,
$password,
@@ -51,7 +34,7 @@ public function connect(array $params, $username = null, $password = null, array
|| true === $driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES]
)
) {
- $pdo->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES, true);
+ $connection->getWrappedConnection()->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES, true);
}
/* defining client_encoding via SET NAMES to avoid inconsistent DSN support
@@ -59,10 +42,10 @@ public function connect(array $params, $username = null, $password = null, array
* - passing client_encoding via the 'options' param breaks pgbouncer support
*/
if (isset($params['charset'])) {
- $pdo->query('SET NAMES \''.$params['charset'].'\'');
+ $connection->query('SET NAMES \'' . $params['charset'] . '\'');
}
- return $pdo;
+ return $connection;
} catch (PDOException $e) {
throw DBALException::driverException($this, $e);
}
diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php
index 096f7a2b64f..83fa6a19025 100644
--- a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php
+++ b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\PDOSqlite;
@@ -53,7 +36,7 @@ public function connect(array $params, $username = null, $password = null, array
}
try {
- $pdo = new PDOConnection(
+ $connection = new PDOConnection(
$this->_constructPdoDsn($params),
$username,
$password,
@@ -63,11 +46,13 @@ public function connect(array $params, $username = null, $password = null, array
throw DBALException::driverException($this, $ex);
}
+ $pdo = $connection->getWrappedConnection();
+
foreach ($this->_userDefinedFunctions as $fn => $data) {
$pdo->sqliteCreateFunction($fn, $data['callback'], $data['numArgs']);
}
- return $pdo;
+ return $connection;
}
/**
diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php
index 7ce7e8a76b6..1e4574bd7b5 100644
--- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php
+++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php
@@ -1,25 +1,9 @@
.
- */
namespace Doctrine\DBAL\Driver\PDOSqlsrv;
use Doctrine\DBAL\Driver\PDOConnection;
+use Doctrine\DBAL\Driver\PDOStatement;
use Doctrine\DBAL\ParameterType;
use function strpos;
use function substr;
@@ -31,15 +15,6 @@
*/
class Connection extends PDOConnection implements \Doctrine\DBAL\Driver\Connection
{
- /**
- * {@inheritdoc}
- */
- public function __construct($dsn, $user = null, $password = null, array $options = null)
- {
- parent::__construct($dsn, $user, $password, $options);
- $this->setAttribute(\PDO::ATTR_STATEMENT_CLASS, [Statement::class, []]);
- }
-
/**
* {@inheritDoc}
*/
@@ -69,4 +44,12 @@ public function quote($value, $type = ParameterType::STRING)
return $val;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function createStatement(\PDOStatement $stmt) : PDOStatement
+ {
+ return new Statement($stmt);
+ }
}
diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php
index d65bcd69064..ea17a350702 100644
--- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php
+++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\PDOSqlsrv;
diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php
index 82e2c3e3565..8af01d1fb51 100644
--- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php
+++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\PDOSqlsrv;
diff --git a/lib/Doctrine/DBAL/Driver/PDOStatement.php b/lib/Doctrine/DBAL/Driver/PDOStatement.php
index ca07596b677..271824bd9a7 100644
--- a/lib/Doctrine/DBAL/Driver/PDOStatement.php
+++ b/lib/Doctrine/DBAL/Driver/PDOStatement.php
@@ -1,26 +1,10 @@
.
- */
namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\ParameterType;
+use IteratorAggregate;
use PDO;
use const E_USER_DEPRECATED;
use function sprintf;
@@ -32,7 +16,7 @@
*
* @since 2.0
*/
-class PDOStatement extends \PDOStatement implements Statement
+class PDOStatement implements IteratorAggregate, Statement
{
/**
* @var int[]
@@ -58,33 +42,24 @@ class PDOStatement extends \PDOStatement implements Statement
];
/**
- * Protected constructor.
+ * @var \PDOStatement
*/
- protected function __construct()
+ private $stmt;
+
+ public function __construct(\PDOStatement $stmt)
{
+ $this->stmt = $stmt;
}
/**
* {@inheritdoc}
*/
- public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
+ public function setFetchMode($fetchMode, ...$args)
{
$fetchMode = $this->convertFetchMode($fetchMode);
- // This thin wrapper is necessary to shield against the weird signature
- // of PDOStatement::setFetchMode(): even if the second and third
- // parameters are optional, PHP will not let us remove it from this
- // declaration.
try {
- if ($arg2 === null && $arg3 === null) {
- return parent::setFetchMode($fetchMode);
- }
-
- if ($arg3 === null) {
- return parent::setFetchMode($fetchMode, $arg2);
- }
-
- return parent::setFetchMode($fetchMode, $arg2, $arg3);
+ return $this->stmt->setFetchMode($fetchMode, ...$args);
} catch (\PDOException $exception) {
throw new PDOException($exception);
}
@@ -98,7 +73,7 @@ public function bindValue($param, $value, $type = ParameterType::STRING)
$type = $this->convertParamType($type);
try {
- return parent::bindValue($param, $value, $type);
+ return $this->stmt->bindValue($param, $value, $type);
} catch (\PDOException $exception) {
throw new PDOException($exception);
}
@@ -112,7 +87,7 @@ public function bindParam($column, &$variable, $type = ParameterType::STRING, $l
$type = $this->convertParamType($type);
try {
- return parent::bindParam($column, $variable, $type, $length, $driverOptions);
+ return $this->stmt->bindParam($column, $variable, $type, $length, $driverOptions);
} catch (\PDOException $exception) {
throw new PDOException($exception);
}
@@ -124,7 +99,7 @@ public function bindParam($column, &$variable, $type = ParameterType::STRING, $l
public function closeCursor()
{
try {
- return parent::closeCursor();
+ return $this->stmt->closeCursor();
} catch (\PDOException $exception) {
// Exceptions not allowed by the interface.
// In case driver implementations do not adhere to the interface, silence exceptions here.
@@ -132,13 +107,37 @@ public function closeCursor()
}
}
+ /**
+ * {@inheritdoc}
+ */
+ public function columnCount()
+ {
+ return $this->stmt->columnCount();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function errorCode()
+ {
+ return $this->stmt->errorCode();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function errorInfo()
+ {
+ return $this->stmt->errorInfo();
+ }
+
/**
* {@inheritdoc}
*/
public function execute($params = null)
{
try {
- return parent::execute($params);
+ return $this->stmt->execute($params);
} catch (\PDOException $exception) {
throw new PDOException($exception);
}
@@ -147,24 +146,24 @@ public function execute($params = null)
/**
* {@inheritdoc}
*/
- public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
+ public function rowCount() : int
+ {
+ return $this->stmt->rowCount();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function fetch($fetchMode = null, ...$args)
{
$fetchMode = $this->convertFetchMode($fetchMode);
try {
- if ($fetchMode === null && \PDO::FETCH_ORI_NEXT === $cursorOrientation && 0 === $cursorOffset) {
- return parent::fetch();
- }
-
- if (\PDO::FETCH_ORI_NEXT === $cursorOrientation && 0 === $cursorOffset) {
- return parent::fetch($fetchMode);
- }
-
- if (0 === $cursorOffset) {
- return parent::fetch($fetchMode, $cursorOrientation);
+ if ($fetchMode === null) {
+ return $this->stmt->fetch();
}
- return parent::fetch($fetchMode, $cursorOrientation, $cursorOffset);
+ return $this->stmt->fetch($fetchMode, ...$args);
} catch (\PDOException $exception) {
throw new PDOException($exception);
}
@@ -173,24 +172,16 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
/**
* {@inheritdoc}
*/
- public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
+ public function fetchAll($fetchMode = null, ...$args)
{
$fetchMode = $this->convertFetchMode($fetchMode);
try {
- if ($fetchMode === null && null === $fetchArgument && null === $ctorArgs) {
- return parent::fetchAll();
- }
-
- if (null === $fetchArgument && null === $ctorArgs) {
- return parent::fetchAll($fetchMode);
+ if ($fetchMode === null) {
+ return $this->stmt->fetchAll();
}
- if (null === $ctorArgs) {
- return parent::fetchAll($fetchMode, $fetchArgument);
- }
-
- return parent::fetchAll($fetchMode, $fetchArgument, $ctorArgs);
+ return $this->stmt->fetchAll($fetchMode, ...$args);
} catch (\PDOException $exception) {
throw new PDOException($exception);
}
@@ -202,7 +193,7 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n
public function fetchColumn($columnIndex = 0)
{
try {
- return parent::fetchColumn($columnIndex);
+ return $this->stmt->fetchColumn($columnIndex);
} catch (\PDOException $exception) {
throw new PDOException($exception);
}
@@ -252,4 +243,12 @@ private function convertFetchMode(?int $fetchMode) : ?int
return self::FETCH_MODE_MAP[$fetchMode];
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getIterator()
+ {
+ yield from $this->stmt;
+ }
}
diff --git a/lib/Doctrine/DBAL/Driver/PingableConnection.php b/lib/Doctrine/DBAL/Driver/PingableConnection.php
index 8c85a82c839..043bb9704ee 100644
--- a/lib/Doctrine/DBAL/Driver/PingableConnection.php
+++ b/lib/Doctrine/DBAL/Driver/PingableConnection.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver;
diff --git a/lib/Doctrine/DBAL/Driver/ResultStatement.php b/lib/Doctrine/DBAL/Driver/ResultStatement.php
index b03862ff6e3..34f40600fbb 100644
--- a/lib/Doctrine/DBAL/Driver/ResultStatement.php
+++ b/lib/Doctrine/DBAL/Driver/ResultStatement.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver;
@@ -45,62 +28,43 @@ public function columnCount();
/**
* Sets the fetch mode to use while iterating this statement.
*
- * @param int $fetchMode The fetch mode must be one of the {@link \Doctrine\DBAL\FetchMode} constants.
- * @param mixed $arg2
- * @param mixed $arg3
+ * @param int $fetchMode Controls how the next row will be returned to the caller.
+ * The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants.
+ * @param array $args Optional mode-specific arguments (see {@link self::fetchAll()}).
*
* @return bool
*/
- public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null);
+ public function setFetchMode($fetchMode, ...$args);
/**
* Returns the next row of a result set.
*
- * @param int|null $fetchMode Controls how the next row will be returned to the caller.
- * The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants,
- * defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.
- * @param int $cursorOrientation For a ResultStatement object representing a scrollable cursor,
- * this value determines which row will be returned to the caller.
- * This value must be one of the \PDO::FETCH_ORI_* constants,
- * defaulting to \PDO::FETCH_ORI_NEXT. To request a scrollable
- * cursor for your ResultStatement object, you must set the \PDO::ATTR_CURSOR
- * attribute to \PDO::CURSOR_SCROLL when you prepare the SQL statement with
- * \PDO::prepare().
- * @param int $cursorOffset For a ResultStatement object representing a scrollable cursor for which the
- * cursorOrientation parameter is set to \PDO::FETCH_ORI_ABS, this value
- * specifies the absolute number of the row in the result set that shall be
- * fetched.
- * For a ResultStatement object representing a scrollable cursor for which the
- * cursorOrientation parameter is set to \PDO::FETCH_ORI_REL, this value
- * specifies the row to fetch relative to the cursor position before
- * ResultStatement::fetch() was called.
+ * @param int|null $fetchMode Controls how the next row will be returned to the caller.
+ * The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants,
+ * defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.
+ * @param array $args Optional mode-specific arguments (see {@link self::fetchAll()}).
*
* @return mixed The return value of this method on success depends on the fetch mode. In all cases, FALSE is
* returned on failure.
*/
- public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0);
+ public function fetch($fetchMode = null, ...$args);
/**
* Returns an array containing all of the result set rows.
*
- * @param int|null $fetchMode Controls how the next row will be returned to the caller.
- * The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants,
- * defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.
- * @param int|null $fetchArgument This argument has a different meaning depending on the value of the $fetchMode parameter:
- * * {@link \Doctrine\DBAL\FetchMode::COLUMN}:
- * Returns the indicated 0-indexed column.
- * * {@link \Doctrine\DBAL\FetchMode::CUSTOM_OBJECT}:
- * Returns instances of the specified class, mapping the columns of each row
- * to named properties in the class.
- * * \PDO::FETCH_FUNC: Returns the results of calling the specified function, using each row's
- * columns as parameters in the call.
- * @param array|null $ctorArgs Controls how the next row will be returned to the caller.
- * The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants,
- * defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.
+ * @param int|null $fetchMode Controls how the next row will be returned to the caller.
+ * The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants,
+ * defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.
+ * @param array $args Optional mode-specific arguments. Supported modes:
+ * * {@link \Doctrine\DBAL\FetchMode::COLUMN}
+ * 1. The 0-indexed column to be returned.
+ * * {@link \Doctrine\DBAL\FetchMode::CUSTOM_OBJECT}
+ * 1. The classname of the object to be created,
+ * 2. Array of constructor arguments
*
* @return array
*/
- public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null);
+ public function fetchAll($fetchMode = null, ...$args);
/**
* Returns a single column from the next row of a result set or FALSE if there are no more rows.
diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php
index 1ff0b04b1ba..d8672f394f4 100644
--- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php
+++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\SQLAnywhere;
diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php
index 29542252c1b..84438fb2aef 100644
--- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php
+++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php
@@ -1,28 +1,12 @@
.
- */
namespace Doctrine\DBAL\Driver\SQLAnywhere;
use Doctrine\DBAL\Driver\Connection;
+use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
+use Doctrine\DBAL\Driver\Statement as DriverStatement;
use Doctrine\DBAL\ParameterType;
-use function func_get_args;
use function is_float;
use function is_int;
use function is_resource;
@@ -135,7 +119,7 @@ public function errorInfo()
/**
* {@inheritdoc}
*/
- public function exec($statement)
+ public function exec(string $statement) : int
{
if (false === sasql_real_query($this->connection, $statement)) {
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
@@ -167,19 +151,17 @@ public function lastInsertId($name = null)
/**
* {@inheritdoc}
*/
- public function prepare($prepareString)
+ public function prepare(string $sql) : DriverStatement
{
- return new SQLAnywhereStatement($this->connection, $prepareString);
+ return new SQLAnywhereStatement($this->connection, $sql);
}
/**
* {@inheritdoc}
*/
- public function query()
+ public function query(string $sql) : ResultStatement
{
- $args = func_get_args();
- $stmt = $this->prepare($args[0]);
-
+ $stmt = $this->prepare($sql);
$stmt->execute();
return $stmt;
diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php
index 2a89206d782..061cbd9bdc8 100644
--- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php
+++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\SQLAnywhere;
diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php
index 5605e525ff2..e0c5f82dcc3 100644
--- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php
+++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\SQLAnywhere;
@@ -26,9 +9,6 @@
use IteratorAggregate;
use const SASQL_BOTH;
use function array_key_exists;
-use function call_user_func_array;
-use function func_get_args;
-use function func_num_args;
use function gettype;
use function is_array;
use function is_numeric;
@@ -223,7 +203,7 @@ public function execute($params = null)
*
* @throws SQLAnywhereException
*/
- public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
+ public function fetch($fetchMode = null, ...$args)
{
if ( ! is_resource($this->result)) {
return false;
@@ -245,10 +225,9 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
$className = $this->defaultFetchClass;
$ctorArgs = $this->defaultFetchClassCtorArgs;
- if (func_num_args() >= 2) {
- $args = func_get_args();
- $className = $args[1];
- $ctorArgs = $args[2] ?? [];
+ if (count($args) > 0) {
+ $className = $args[0];
+ $ctorArgs = $args[1] ?? [];
}
$result = sasql_fetch_object($this->result);
@@ -273,25 +252,25 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
/**
* {@inheritdoc}
*/
- public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
+ public function fetchAll($fetchMode = null, ...$args)
{
$rows = [];
switch ($fetchMode) {
case FetchMode::CUSTOM_OBJECT:
- while ($row = call_user_func_array([$this, 'fetch'], func_get_args())) {
+ while (($row = $this->fetch($fetchMode, ...$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;
}
}
@@ -324,7 +303,7 @@ public function getIterator()
/**
* {@inheritdoc}
*/
- public function rowCount()
+ public function rowCount() : int
{
return sasql_stmt_affected_rows($this->stmt);
}
@@ -332,7 +311,7 @@ public function rowCount()
/**
* {@inheritdoc}
*/
- public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
+ public function setFetchMode($fetchMode, ...$args)
{
$this->defaultFetchMode = $fetchMode;
$this->defaultFetchClass = $arg2 ? $arg2 : $this->defaultFetchClass;
diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php b/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php
index da0409f24c5..0d74217d04f 100644
--- a/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php
+++ b/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\SQLSrv;
diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php b/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php
index 909f1e444be..44a5b9a83f8 100644
--- a/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php
+++ b/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\SQLSrv;
diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php
index 6cdd4bca97f..860f0d22cdc 100644
--- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php
+++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php
@@ -1,29 +1,13 @@
.
- */
namespace Doctrine\DBAL\Driver\SQLSrv;
use Doctrine\DBAL\Driver\Connection;
+use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
+use Doctrine\DBAL\Driver\Statement as DriverStatement;
use Doctrine\DBAL\ParameterType;
use const SQLSRV_ERR_ERRORS;
-use function func_get_args;
use function is_float;
use function is_int;
use function sprintf;
@@ -96,7 +80,7 @@ public function requiresQueryForServerVersion()
/**
* {@inheritDoc}
*/
- public function prepare($sql)
+ public function prepare(string $sql) : DriverStatement
{
return new SQLSrvStatement($this->conn, $sql, $this->lastInsertId);
}
@@ -104,10 +88,8 @@ public function prepare($sql)
/**
* {@inheritDoc}
*/
- public function query()
+ public function query(string $sql) : ResultStatement
{
- $args = func_get_args();
- $sql = $args[0];
$stmt = $this->prepare($sql);
$stmt->execute();
@@ -132,7 +114,7 @@ public function quote($value, $type = ParameterType::STRING)
/**
* {@inheritDoc}
*/
- public function exec($statement)
+ public function exec(string $statement) : int
{
$stmt = sqlsrv_query($this->conn, $statement);
diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php
index 3223c113608..4eee85f5e66 100644
--- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php
+++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\SQLSrv;
diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php
index f4d450177a8..77242a2495e 100644
--- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php
+++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver\SQLSrv;
@@ -32,7 +15,6 @@
use const SQLSRV_PARAM_IN;
use function array_key_exists;
use function count;
-use function func_get_args;
use function in_array;
use function is_numeric;
use function sqlsrv_errors;
@@ -307,11 +289,17 @@ private function prepare()
/**
* {@inheritdoc}
*/
- public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
+ public function setFetchMode($fetchMode, ...$args)
{
- $this->defaultFetchMode = $fetchMode;
- $this->defaultFetchClass = $arg2 ?: $this->defaultFetchClass;
- $this->defaultFetchClassCtorArgs = $arg3 ? (array) $arg3 : $this->defaultFetchClassCtorArgs;
+ $this->defaultFetchMode = $fetchMode;
+
+ if (isset($args[0])) {
+ $this->defaultFetchClass = $args[0];
+ }
+
+ if (isset($args[1])) {
+ $this->defaultFetchClassCtorArgs = (array) $args[1];
+ }
return true;
}
@@ -329,7 +317,7 @@ public function getIterator()
*
* @throws SQLSrvException
*/
- public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
+ public function fetch($fetchMode = null, ...$args)
{
// do not try fetching from the statement if it's not expected to contain result
// in order to prevent exceptional situation
@@ -337,7 +325,6 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
return false;
}
- $args = func_get_args();
$fetchMode = $fetchMode ?: $this->defaultFetchMode;
if ($fetchMode === FetchMode::COLUMN) {
@@ -352,9 +339,9 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
$className = $this->defaultFetchClass;
$ctorArgs = $this->defaultFetchClassCtorArgs;
- if (count($args) >= 2) {
- $className = $args[1];
- $ctorArgs = $args[2] ?? [];
+ if (count($args) > 0) {
+ $className = $args[0];
+ $ctorArgs = $args[1] ?? [];
}
return sqlsrv_fetch_object($this->stmt, $className, $ctorArgs) ?: false;
@@ -366,13 +353,13 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
/**
* {@inheritdoc}
*/
- public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
+ public function fetchAll($fetchMode = null, ...$args)
{
$rows = [];
switch ($fetchMode) {
case FetchMode::CUSTOM_OBJECT:
- while (($row = $this->fetch(...func_get_args())) !== false) {
+ while (($row = $this->fetch($fetchMode, ...$args)) !== false) {
$rows[] = $row;
}
break;
@@ -409,7 +396,7 @@ public function fetchColumn($columnIndex = 0)
/**
* {@inheritdoc}
*/
- public function rowCount()
+ public function rowCount() : int
{
return sqlsrv_rows_affected($this->stmt);
}
diff --git a/lib/Doctrine/DBAL/Driver/ServerInfoAwareConnection.php b/lib/Doctrine/DBAL/Driver/ServerInfoAwareConnection.php
index f47ad0b2701..588ec859720 100644
--- a/lib/Doctrine/DBAL/Driver/ServerInfoAwareConnection.php
+++ b/lib/Doctrine/DBAL/Driver/ServerInfoAwareConnection.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver;
diff --git a/lib/Doctrine/DBAL/Driver/Statement.php b/lib/Doctrine/DBAL/Driver/Statement.php
index 15b6bee1bae..2530df52dad 100644
--- a/lib/Doctrine/DBAL/Driver/Statement.php
+++ b/lib/Doctrine/DBAL/Driver/Statement.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Driver;
@@ -71,8 +54,7 @@ public function bindValue($param, $value, $type = ParameterType::STRING);
* question mark placeholders, this will be the 1-indexed position of the parameter.
* @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
* @param int|null $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType}
- * constants. To return an INOUT parameter from a stored procedure, use the bitwise
- * OR operator to set the PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter.
+ * constants.
* @param int|null $length You must specify maxlength when using an OUT bind
* so that PHP allocates enough memory to hold the returned value.
*
@@ -126,5 +108,5 @@ public function execute($params = null);
*
* @return int The number of rows.
*/
- public function rowCount();
+ public function rowCount() : int;
}
diff --git a/lib/Doctrine/DBAL/DriverManager.php b/lib/Doctrine/DBAL/DriverManager.php
index 22ae8ac3264..c99dddf0723 100644
--- a/lib/Doctrine/DBAL/DriverManager.php
+++ b/lib/Doctrine/DBAL/DriverManager.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL;
@@ -58,7 +41,6 @@ final class DriverManager
'ibm_db2' => 'Doctrine\DBAL\Driver\IBMDB2\DB2Driver',
'pdo_sqlsrv' => 'Doctrine\DBAL\Driver\PDOSqlsrv\Driver',
'mysqli' => 'Doctrine\DBAL\Driver\Mysqli\Driver',
- 'drizzle_pdo_mysql' => 'Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver',
'sqlanywhere' => 'Doctrine\DBAL\Driver\SQLAnywhere\Driver',
'sqlsrv' => 'Doctrine\DBAL\Driver\SQLSrv\Driver',
];
@@ -104,7 +86,6 @@ private function __construct()
* sqlanywhere
* sqlsrv
* ibm_db2 (unstable)
- * drizzle_pdo_mysql
*
* OR 'driverClass' that contains the full class name (with namespace) of the
* driver class to instantiate.
diff --git a/lib/Doctrine/DBAL/Event/ConnectionEventArgs.php b/lib/Doctrine/DBAL/Event/ConnectionEventArgs.php
index fd82638e771..5f8abc1ee59 100644
--- a/lib/Doctrine/DBAL/Event/ConnectionEventArgs.php
+++ b/lib/Doctrine/DBAL/Event/ConnectionEventArgs.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Event;
diff --git a/lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php b/lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php
index 043f7b5ebc9..d65f3f799a1 100644
--- a/lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php
+++ b/lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Event\Listeners;
diff --git a/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php b/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php
index 851986cc1a4..f024a92190b 100644
--- a/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php
+++ b/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Event\Listeners;
diff --git a/lib/Doctrine/DBAL/Event/Listeners/SQLSessionInit.php b/lib/Doctrine/DBAL/Event/Listeners/SQLSessionInit.php
index 767c804821f..3eab0e8b58b 100644
--- a/lib/Doctrine/DBAL/Event/Listeners/SQLSessionInit.php
+++ b/lib/Doctrine/DBAL/Event/Listeners/SQLSessionInit.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Event\Listeners;
diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php
index 7cb235ea18b..b4f281f6098 100644
--- a/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php
+++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Event;
diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php
index fdafb45a7a4..55392c67cae 100644
--- a/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php
+++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Event;
diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php
index 8e60b2c5f6b..4dcbbe0963d 100644
--- a/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php
+++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Event;
diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php
index 52413ce9173..2a6aa93b2dd 100644
--- a/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php
+++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Event;
diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php
index 697660442a5..f0d0500c568 100644
--- a/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php
+++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Event;
diff --git a/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php
index 14bb8df73b3..192a7400aef 100644
--- a/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php
+++ b/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Event;
diff --git a/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php
index 824e243b135..e3f414d575c 100644
--- a/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php
+++ b/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Event;
diff --git a/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php
index 7993b3adb15..0e20c51aed8 100644
--- a/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php
+++ b/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Event;
diff --git a/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php
index b3c90422121..b114ce5d0d9 100644
--- a/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php
+++ b/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Event;
diff --git a/lib/Doctrine/DBAL/Event/SchemaEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaEventArgs.php
index db12e57ad3b..4d19b1c0b4f 100644
--- a/lib/Doctrine/DBAL/Event/SchemaEventArgs.php
+++ b/lib/Doctrine/DBAL/Event/SchemaEventArgs.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Event;
diff --git a/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php
index 3fd1d4bf7da..2095a6a6c27 100644
--- a/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php
+++ b/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Event;
diff --git a/lib/Doctrine/DBAL/Events.php b/lib/Doctrine/DBAL/Events.php
index 0d31504c70a..9a8c4faa244 100644
--- a/lib/Doctrine/DBAL/Events.php
+++ b/lib/Doctrine/DBAL/Events.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL;
diff --git a/lib/Doctrine/DBAL/Exception/ConnectionException.php b/lib/Doctrine/DBAL/Exception/ConnectionException.php
index 8d976dcb325..134ee24db4e 100644
--- a/lib/Doctrine/DBAL/Exception/ConnectionException.php
+++ b/lib/Doctrine/DBAL/Exception/ConnectionException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Exception;
diff --git a/lib/Doctrine/DBAL/Exception/ConstraintViolationException.php b/lib/Doctrine/DBAL/Exception/ConstraintViolationException.php
index 8dd1cb69452..9168edd5cd7 100644
--- a/lib/Doctrine/DBAL/Exception/ConstraintViolationException.php
+++ b/lib/Doctrine/DBAL/Exception/ConstraintViolationException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Exception;
diff --git a/lib/Doctrine/DBAL/Exception/DatabaseObjectExistsException.php b/lib/Doctrine/DBAL/Exception/DatabaseObjectExistsException.php
index 279aae9a5a3..2d1be341331 100644
--- a/lib/Doctrine/DBAL/Exception/DatabaseObjectExistsException.php
+++ b/lib/Doctrine/DBAL/Exception/DatabaseObjectExistsException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Exception;
diff --git a/lib/Doctrine/DBAL/Exception/DatabaseObjectNotFoundException.php b/lib/Doctrine/DBAL/Exception/DatabaseObjectNotFoundException.php
index fbca22d9942..07473043f00 100644
--- a/lib/Doctrine/DBAL/Exception/DatabaseObjectNotFoundException.php
+++ b/lib/Doctrine/DBAL/Exception/DatabaseObjectNotFoundException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Exception;
diff --git a/lib/Doctrine/DBAL/Exception/DeadlockException.php b/lib/Doctrine/DBAL/Exception/DeadlockException.php
index 05af11e4b6f..042537634ac 100644
--- a/lib/Doctrine/DBAL/Exception/DeadlockException.php
+++ b/lib/Doctrine/DBAL/Exception/DeadlockException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Exception;
diff --git a/lib/Doctrine/DBAL/Exception/DriverException.php b/lib/Doctrine/DBAL/Exception/DriverException.php
index 08b7935a0c0..42328cc62fd 100644
--- a/lib/Doctrine/DBAL/Exception/DriverException.php
+++ b/lib/Doctrine/DBAL/Exception/DriverException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Exception;
diff --git a/lib/Doctrine/DBAL/Exception/ForeignKeyConstraintViolationException.php b/lib/Doctrine/DBAL/Exception/ForeignKeyConstraintViolationException.php
index d244855a16d..5cab4d982b5 100644
--- a/lib/Doctrine/DBAL/Exception/ForeignKeyConstraintViolationException.php
+++ b/lib/Doctrine/DBAL/Exception/ForeignKeyConstraintViolationException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Exception;
diff --git a/lib/Doctrine/DBAL/Exception/InvalidArgumentException.php b/lib/Doctrine/DBAL/Exception/InvalidArgumentException.php
index 5b811227bdd..be5d061b3e5 100644
--- a/lib/Doctrine/DBAL/Exception/InvalidArgumentException.php
+++ b/lib/Doctrine/DBAL/Exception/InvalidArgumentException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Exception;
diff --git a/lib/Doctrine/DBAL/Exception/InvalidFieldNameException.php b/lib/Doctrine/DBAL/Exception/InvalidFieldNameException.php
index e0b1013fe4c..81db4dff3f4 100644
--- a/lib/Doctrine/DBAL/Exception/InvalidFieldNameException.php
+++ b/lib/Doctrine/DBAL/Exception/InvalidFieldNameException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Exception;
diff --git a/lib/Doctrine/DBAL/Exception/LockWaitTimeoutException.php b/lib/Doctrine/DBAL/Exception/LockWaitTimeoutException.php
index 915e11b8b93..2b805c2ce03 100644
--- a/lib/Doctrine/DBAL/Exception/LockWaitTimeoutException.php
+++ b/lib/Doctrine/DBAL/Exception/LockWaitTimeoutException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Exception;
diff --git a/lib/Doctrine/DBAL/Exception/NonUniqueFieldNameException.php b/lib/Doctrine/DBAL/Exception/NonUniqueFieldNameException.php
index 7b214e3b946..098bfeaf9e9 100644
--- a/lib/Doctrine/DBAL/Exception/NonUniqueFieldNameException.php
+++ b/lib/Doctrine/DBAL/Exception/NonUniqueFieldNameException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Exception;
diff --git a/lib/Doctrine/DBAL/Exception/NotNullConstraintViolationException.php b/lib/Doctrine/DBAL/Exception/NotNullConstraintViolationException.php
index a1f45b92a44..7a7909d4f45 100644
--- a/lib/Doctrine/DBAL/Exception/NotNullConstraintViolationException.php
+++ b/lib/Doctrine/DBAL/Exception/NotNullConstraintViolationException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Exception;
diff --git a/lib/Doctrine/DBAL/Exception/ReadOnlyException.php b/lib/Doctrine/DBAL/Exception/ReadOnlyException.php
index 0345e88fce0..8920a102b06 100644
--- a/lib/Doctrine/DBAL/Exception/ReadOnlyException.php
+++ b/lib/Doctrine/DBAL/Exception/ReadOnlyException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Exception;
diff --git a/lib/Doctrine/DBAL/Exception/RetryableException.php b/lib/Doctrine/DBAL/Exception/RetryableException.php
index 6b019dcc472..54335734118 100644
--- a/lib/Doctrine/DBAL/Exception/RetryableException.php
+++ b/lib/Doctrine/DBAL/Exception/RetryableException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Exception;
diff --git a/lib/Doctrine/DBAL/Exception/ServerException.php b/lib/Doctrine/DBAL/Exception/ServerException.php
index 36460ee0d64..310d8c7bc5a 100644
--- a/lib/Doctrine/DBAL/Exception/ServerException.php
+++ b/lib/Doctrine/DBAL/Exception/ServerException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Exception;
diff --git a/lib/Doctrine/DBAL/Exception/SyntaxErrorException.php b/lib/Doctrine/DBAL/Exception/SyntaxErrorException.php
index 97b8fd25f3e..9e41c891f2b 100644
--- a/lib/Doctrine/DBAL/Exception/SyntaxErrorException.php
+++ b/lib/Doctrine/DBAL/Exception/SyntaxErrorException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Exception;
diff --git a/lib/Doctrine/DBAL/Exception/TableExistsException.php b/lib/Doctrine/DBAL/Exception/TableExistsException.php
index c90bfb476c4..1bfef855a5b 100644
--- a/lib/Doctrine/DBAL/Exception/TableExistsException.php
+++ b/lib/Doctrine/DBAL/Exception/TableExistsException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Exception;
diff --git a/lib/Doctrine/DBAL/Exception/TableNotFoundException.php b/lib/Doctrine/DBAL/Exception/TableNotFoundException.php
index 90793b909de..ea6a6d14a2e 100644
--- a/lib/Doctrine/DBAL/Exception/TableNotFoundException.php
+++ b/lib/Doctrine/DBAL/Exception/TableNotFoundException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Exception;
diff --git a/lib/Doctrine/DBAL/Exception/UniqueConstraintViolationException.php b/lib/Doctrine/DBAL/Exception/UniqueConstraintViolationException.php
index cd117738dd9..9f235cad377 100644
--- a/lib/Doctrine/DBAL/Exception/UniqueConstraintViolationException.php
+++ b/lib/Doctrine/DBAL/Exception/UniqueConstraintViolationException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Exception;
diff --git a/lib/Doctrine/DBAL/FetchMode.php b/lib/Doctrine/DBAL/FetchMode.php
index a3e7f3ba601..65af014f1e0 100644
--- a/lib/Doctrine/DBAL/FetchMode.php
+++ b/lib/Doctrine/DBAL/FetchMode.php
@@ -15,7 +15,7 @@ final class FetchMode
*
* @see \PDO::FETCH_ASSOC
*/
- public const ASSOCIATIVE = \PDO::FETCH_ASSOC;
+ public const ASSOCIATIVE = 2;
/**
* Specifies that the fetch method shall return each row as an array indexed
@@ -24,7 +24,7 @@ final class FetchMode
*
* @see \PDO::FETCH_NUM
*/
- public const NUMERIC = \PDO::FETCH_NUM;
+ public const NUMERIC = 3;
/**
* Specifies that the fetch method shall return each row as an array indexed
@@ -33,7 +33,7 @@ final class FetchMode
*
* @see \PDO::FETCH_BOTH
*/
- public const MIXED = \PDO::FETCH_BOTH;
+ public const MIXED = 4;
/**
* Specifies that the fetch method shall return each row as an object with
@@ -42,7 +42,7 @@ final class FetchMode
*
* @see \PDO::FETCH_OBJ
*/
- public const STANDARD_OBJECT = \PDO::FETCH_OBJ;
+ public const STANDARD_OBJECT = 5;
/**
* Specifies that the fetch method shall return only a single requested
@@ -50,7 +50,7 @@ final class FetchMode
*
* @see \PDO::FETCH_COLUMN
*/
- public const COLUMN = \PDO::FETCH_COLUMN;
+ public const COLUMN = 7;
/**
* Specifies that the fetch method shall return a new instance of the
@@ -58,7 +58,7 @@ final class FetchMode
*
* @see \PDO::FETCH_CLASS
*/
- public const CUSTOM_OBJECT = \PDO::FETCH_CLASS;
+ public const CUSTOM_OBJECT = 8;
/**
* This class cannot be instantiated.
diff --git a/lib/Doctrine/DBAL/Id/TableGenerator.php b/lib/Doctrine/DBAL/Id/TableGenerator.php
index 068eb6056bf..4c21e5a1dbb 100644
--- a/lib/Doctrine/DBAL/Id/TableGenerator.php
+++ b/lib/Doctrine/DBAL/Id/TableGenerator.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Id;
diff --git a/lib/Doctrine/DBAL/Id/TableGeneratorSchemaVisitor.php b/lib/Doctrine/DBAL/Id/TableGeneratorSchemaVisitor.php
index 619a92f7b4d..b92d421e6d7 100644
--- a/lib/Doctrine/DBAL/Id/TableGeneratorSchemaVisitor.php
+++ b/lib/Doctrine/DBAL/Id/TableGeneratorSchemaVisitor.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Id;
diff --git a/lib/Doctrine/DBAL/LockMode.php b/lib/Doctrine/DBAL/LockMode.php
index 8d78180ede2..5b0c99c507e 100644
--- a/lib/Doctrine/DBAL/LockMode.php
+++ b/lib/Doctrine/DBAL/LockMode.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL;
diff --git a/lib/Doctrine/DBAL/Logging/DebugStack.php b/lib/Doctrine/DBAL/Logging/DebugStack.php
index 4cffaa67fce..b5350a98782 100644
--- a/lib/Doctrine/DBAL/Logging/DebugStack.php
+++ b/lib/Doctrine/DBAL/Logging/DebugStack.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Logging;
@@ -31,7 +14,7 @@
* @author Jonathan Wage
* @author Roman Borschel
*/
-class DebugStack implements SQLLogger
+final class DebugStack implements SQLLogger
{
/**
* Executed SQL queries.
@@ -60,7 +43,7 @@ class DebugStack implements SQLLogger
/**
* {@inheritdoc}
*/
- public function startQuery($sql, array $params = null, array $types = null)
+ public function startQuery(string $sql, array $params = [], array $types = []) : void
{
if ($this->enabled) {
$this->start = microtime(true);
@@ -71,7 +54,7 @@ public function startQuery($sql, array $params = null, array $types = null)
/**
* {@inheritdoc}
*/
- public function stopQuery()
+ public function stopQuery() : void
{
if ($this->enabled) {
$this->queries[$this->currentQuery]['executionMS'] = microtime(true) - $this->start;
diff --git a/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php b/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php
index a6c1ae5ea0b..3a813801445 100644
--- a/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php
+++ b/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Logging;
@@ -32,12 +15,12 @@
* @author Jonathan Wage
* @author Roman Borschel
*/
-class EchoSQLLogger implements SQLLogger
+final class EchoSQLLogger implements SQLLogger
{
/**
* {@inheritdoc}
*/
- public function startQuery($sql, array $params = null, array $types = null)
+ public function startQuery(string $sql, array $params = [], array $types = []) : void
{
echo $sql . PHP_EOL;
@@ -53,7 +36,7 @@ public function startQuery($sql, array $params = null, array $types = null)
/**
* {@inheritdoc}
*/
- public function stopQuery()
+ public function stopQuery() : void
{
}
}
diff --git a/lib/Doctrine/DBAL/Logging/LoggerChain.php b/lib/Doctrine/DBAL/Logging/LoggerChain.php
index fee05a4a004..a719c504e9a 100644
--- a/lib/Doctrine/DBAL/Logging/LoggerChain.php
+++ b/lib/Doctrine/DBAL/Logging/LoggerChain.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Logging;
@@ -26,7 +9,7 @@
* @since 2.2
* @author Christophe Coevoet
*/
-class LoggerChain implements SQLLogger
+final class LoggerChain implements SQLLogger
{
/**
* @var \Doctrine\DBAL\Logging\SQLLogger[]
@@ -40,7 +23,7 @@ class LoggerChain implements SQLLogger
*
* @return void
*/
- public function addLogger(SQLLogger $logger)
+ public function addLogger(SQLLogger $logger) : void
{
$this->loggers[] = $logger;
}
@@ -48,7 +31,7 @@ public function addLogger(SQLLogger $logger)
/**
* {@inheritdoc}
*/
- public function startQuery($sql, array $params = null, array $types = null)
+ public function startQuery(string $sql, array $params = [], array $types = []) : void
{
foreach ($this->loggers as $logger) {
$logger->startQuery($sql, $params, $types);
@@ -58,7 +41,7 @@ public function startQuery($sql, array $params = null, array $types = null)
/**
* {@inheritdoc}
*/
- public function stopQuery()
+ public function stopQuery() : void
{
foreach ($this->loggers as $logger) {
$logger->stopQuery();
diff --git a/lib/Doctrine/DBAL/Logging/NullLogger.php b/lib/Doctrine/DBAL/Logging/NullLogger.php
new file mode 100644
index 00000000000..3a925f13ca0
--- /dev/null
+++ b/lib/Doctrine/DBAL/Logging/NullLogger.php
@@ -0,0 +1,25 @@
+.
- */
namespace Doctrine\DBAL\Logging;
@@ -34,18 +17,18 @@ interface SQLLogger
/**
* Logs a SQL statement somewhere.
*
- * @param string $sql The SQL to be executed.
- * @param array|null $params The SQL parameters.
- * @param array|null $types The SQL parameter types.
+ * @param string $sql The SQL to be executed.
+ * @param mixed[] $params The SQL parameters.
+ * @param string[] $types The SQL parameter types.
*
* @return void
*/
- public function startQuery($sql, array $params = null, array $types = null);
+ public function startQuery(string $sql, array $params = [], array $types = []) : void;
/**
* Marks the last started query as stopped. This can be used for timing of queries.
*
* @return void
*/
- public function stopQuery();
+ public function stopQuery() : void;
}
diff --git a/lib/Doctrine/DBAL/ParameterType.php b/lib/Doctrine/DBAL/ParameterType.php
index 362a0514d23..96e80c9c3dd 100644
--- a/lib/Doctrine/DBAL/ParameterType.php
+++ b/lib/Doctrine/DBAL/ParameterType.php
@@ -12,35 +12,35 @@ final class ParameterType
*
* @see \PDO::PARAM_NULL
*/
- public const NULL = \PDO::PARAM_NULL;
+ public const NULL = 0;
/**
* Represents the SQL INTEGER data type.
*
* @see \PDO::PARAM_INT
*/
- public const INTEGER = \PDO::PARAM_INT;
+ public const INTEGER = 1;
/**
* Represents the SQL CHAR, VARCHAR, or other string data type.
*
* @see \PDO::PARAM_STR
*/
- public const STRING = \PDO::PARAM_STR;
+ public const STRING = 2;
/**
* Represents the SQL large object data type.
*
* @see \PDO::PARAM_LOB
*/
- public const LARGE_OBJECT = \PDO::PARAM_LOB;
+ public const LARGE_OBJECT = 3;
/**
* Represents a boolean data type.
*
* @see \PDO::PARAM_BOOL
*/
- public const BOOLEAN = \PDO::PARAM_BOOL;
+ public const BOOLEAN = 5;
/**
* This class cannot be instantiated.
diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
index daf6b8528f4..6761031dca1 100644
--- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms;
@@ -39,6 +22,7 @@
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
+use Doctrine\DBAL\Schema\UniqueConstraint;
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types;
use Doctrine\DBAL\Types\Type;
@@ -1554,15 +1538,30 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE
$options['indexes'] = [];
$options['primary'] = [];
- if (($createFlags&self::CREATE_INDEXES) > 0) {
+ if (($createFlags & self::CREATE_INDEXES) > 0) {
foreach ($table->getIndexes() as $index) {
/* @var $index Index */
- if ($index->isPrimary()) {
- $options['primary'] = $index->getQuotedColumns($this);
- $options['primary_index'] = $index;
- } else {
+ if (! $index->isPrimary()) {
$options['indexes'][$index->getQuotedName($this)] = $index;
+
+ continue;
}
+
+ $options['primary'] = $index->getQuotedColumns($this);
+ $options['primary_index'] = $index;
+ }
+
+ foreach ($table->getUniqueConstraints() as $uniqueConstraint) {
+ /** @var UniqueConstraint $uniqueConstraint */
+ $options['uniqueConstraints'][$uniqueConstraint->getQuotedName($this)] = $uniqueConstraint;
+ }
+ }
+
+ if (($createFlags & self::CREATE_FOREIGNKEYS) > 0) {
+ $options['foreignKeys'] = array();
+
+ foreach ($table->getForeignKeys() as $fkConstraint) {
+ $options['foreignKeys'][] = $fkConstraint;
}
}
@@ -1571,7 +1570,6 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE
foreach ($table->getColumns() as $column) {
/* @var \Doctrine\DBAL\Schema\Column $column */
-
if (null !== $this->_eventManager && $this->_eventManager->hasListeners(Events::onSchemaCreateTableColumn)) {
$eventArgs = new SchemaCreateTableColumnEventArgs($column, $table, $this);
$this->_eventManager->dispatchEvent(Events::onSchemaCreateTableColumn, $eventArgs);
@@ -1599,13 +1597,6 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE
$columns[$columnData['name']] = $columnData;
}
- if (($createFlags&self::CREATE_FOREIGNKEYS) > 0) {
- $options['foreignKeys'] = [];
- foreach ($table->getForeignKeys() as $fkConstraint) {
- $options['foreignKeys'][] = $fkConstraint;
- }
- }
-
if (null !== $this->_eventManager && $this->_eventManager->hasListeners(Events::onSchemaCreateTable)) {
$eventArgs = new SchemaCreateTableEventArgs($table, $columns, $options, $this);
$this->_eventManager->dispatchEvent(Events::onSchemaCreateTable, $eventArgs);
@@ -2373,25 +2364,33 @@ public function getCheckDeclarationSQL(array $definition)
* Obtains DBMS specific SQL code portion needed to set a unique
* constraint declaration to be used in statements like CREATE TABLE.
*
- * @param string $name The name of the unique constraint.
- * @param \Doctrine\DBAL\Schema\Index $index The index definition.
+ * @param string $name The name of the unique constraint.
+ * @param \Doctrine\DBAL\Schema\UniqueConstraint $constraint The unique constraint definition.
*
* @return string DBMS specific SQL code portion needed to set a constraint.
*
* @throws \InvalidArgumentException
*/
- public function getUniqueConstraintDeclarationSQL($name, Index $index)
+ public function getUniqueConstraintDeclarationSQL($name, UniqueConstraint $constraint)
{
- $columns = $index->getQuotedColumns($this);
- $name = new Identifier($name);
+ $columns = $constraint->getQuotedColumns($this);
+ $name = new Identifier($name);
if (count($columns) === 0) {
throw new \InvalidArgumentException("Incomplete definition. 'columns' required.");
}
- return 'CONSTRAINT ' . $name->getQuotedName($this) . ' UNIQUE ('
- . $this->getIndexFieldDeclarationListSQL($columns)
- . ')' . $this->getPartialIndexSQL($index);
+ $flags = ['UNIQUE'];
+
+ if ($constraint->hasFlag('clustered')) {
+ $flags[] = 'CLUSTERED';
+ }
+
+ $constraintName = $name->getQuotedName($this);
+ $constraintName = ! empty($constraintName) ? $constraintName . ' ' : '';
+ $columnListNames = $this->getIndexFieldDeclarationListSQL($columns);
+
+ return sprintf('CONSTRAINT %s%s (%s)', $constraintName, implode(' ', $flags), $columnListNames);
}
/**
@@ -3085,6 +3084,27 @@ public function usesSequenceEmulatedIdentityColumns()
return false;
}
+ /**
+ * Gets the sequence name prefix based on table information.
+ *
+ * @param string $tableName
+ * @param string|null $schemaName
+ *
+ * @return string
+ */
+ public function getSequencePrefix($tableName, $schemaName = null)
+ {
+ if (! $schemaName) {
+ return $tableName;
+ }
+
+ // Prepend the schema name to the table name if there is one
+ return (! $this->supportsSchemas() && $this->canEmulateSchemas())
+ ? $schemaName . '__' . $tableName
+ : $schemaName . '.' . $tableName
+ ;
+ }
+
/**
* Returns the name of the sequence for a particular identity column in a particular table.
*
diff --git a/lib/Doctrine/DBAL/Platforms/DB2Platform.php b/lib/Doctrine/DBAL/Platforms/DB2Platform.php
index df2faab440d..24733ef8357 100644
--- a/lib/Doctrine/DBAL/Platforms/DB2Platform.php
+++ b/lib/Doctrine/DBAL/Platforms/DB2Platform.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms;
@@ -68,21 +51,21 @@ public function getBlobTypeDeclarationSQL(array $field)
public function initializeDoctrineTypeMappings()
{
$this->doctrineTypeMapping = [
- 'smallint' => 'smallint',
- 'bigint' => 'bigint',
- 'integer' => 'integer',
- 'time' => 'time',
- 'date' => 'date',
- 'varchar' => 'string',
- 'character' => 'string',
- 'varbinary' => 'binary',
- 'binary' => 'binary',
- 'clob' => 'text',
- 'blob' => 'blob',
- 'decimal' => 'decimal',
- 'double' => 'float',
- 'real' => 'float',
- 'timestamp' => 'datetime',
+ 'bigint' => 'bigint',
+ 'binary' => 'binary',
+ 'blob' => 'blob',
+ 'character' => 'string',
+ 'clob' => 'text',
+ 'date' => 'date',
+ 'decimal' => 'decimal',
+ 'double' => 'float',
+ 'integer' => 'integer',
+ 'real' => 'float',
+ 'smallint' => 'smallint',
+ 'time' => 'time',
+ 'timestamp' => 'datetime',
+ 'varbinary' => 'binary',
+ 'varchar' => 'string',
];
}
diff --git a/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php b/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php
deleted file mode 100644
index 3037d895e3e..00000000000
--- a/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php
+++ /dev/null
@@ -1,637 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Platforms;
-
-use Doctrine\DBAL\Schema\Identifier;
-use Doctrine\DBAL\Schema\Index;
-use Doctrine\DBAL\Schema\Table;
-use Doctrine\DBAL\Schema\TableDiff;
-use Doctrine\DBAL\Types\BinaryType;
-use function array_merge;
-use function array_unique;
-use function array_values;
-use function count;
-use function func_get_args;
-use function implode;
-use function is_array;
-use function is_bool;
-use function is_numeric;
-use function is_string;
-use function join;
-use function sprintf;
-use function trim;
-
-/**
- * Drizzle platform
- *
- * @author Kim Hemsø Rasmussen
- */
-class DrizzlePlatform extends AbstractPlatform
-{
- /**
- * {@inheritDoc}
- */
- public function getName()
- {
- return 'drizzle';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getIdentifierQuoteCharacter()
- {
- return '`';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getConcatExpression()
- {
- $args = func_get_args();
-
- return 'CONCAT(' . join(', ', (array) $args) . ')';
- }
-
- /**
- * {@inheritdoc}
- */
- protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit)
- {
- $function = '+' === $operator ? 'DATE_ADD' : 'DATE_SUB';
-
- return $function . '(' . $date . ', INTERVAL ' . $interval . ' ' . $unit . ')';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getDateDiffExpression($date1, $date2)
- {
- return 'DATEDIFF(' . $date1 . ', ' . $date2 . ')';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getBooleanTypeDeclarationSQL(array $field)
- {
- return 'BOOLEAN';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getIntegerTypeDeclarationSQL(array $field)
- {
- return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
- }
-
- /**
- * {@inheritDoc}
- */
- protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
- {
- $autoinc = '';
- if ( ! empty($columnDef['autoincrement'])) {
- $autoinc = ' AUTO_INCREMENT';
- }
-
- return $autoinc;
- }
-
- /**
- * {@inheritDoc}
- */
- public function getBigIntTypeDeclarationSQL(array $field)
- {
- return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
- }
-
- /**
- * {@inheritDoc}
- */
- public function getSmallIntTypeDeclarationSQL(array $field)
- {
- return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
- }
-
- /**
- * {@inheritDoc}
- */
- protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed)
- {
- return $length ? 'VARCHAR(' . $length . ')' : 'VARCHAR(255)';
- }
-
- /**
- * {@inheritdoc}
- */
- protected function getBinaryTypeDeclarationSQLSnippet($length, $fixed)
- {
- return 'VARBINARY(' . ($length ?: 255) . ')';
- }
-
- /**
- * {@inheritDoc}
- */
- protected function initializeDoctrineTypeMappings()
- {
- $this->doctrineTypeMapping = [
- 'boolean' => 'boolean',
- 'varchar' => 'string',
- 'varbinary' => 'binary',
- 'integer' => 'integer',
- 'blob' => 'blob',
- 'decimal' => 'decimal',
- 'datetime' => 'datetime',
- 'date' => 'date',
- 'time' => 'time',
- 'text' => 'text',
- 'timestamp' => 'datetime',
- 'double' => 'float',
- 'bigint' => 'bigint',
- ];
- }
-
- /**
- * {@inheritDoc}
- */
- public function getClobTypeDeclarationSQL(array $field)
- {
- return 'TEXT';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getBlobTypeDeclarationSQL(array $field)
- {
- return 'BLOB';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getCreateDatabaseSQL($name)
- {
- return 'CREATE DATABASE ' . $name;
- }
-
- /**
- * {@inheritDoc}
- */
- public function getDropDatabaseSQL($name)
- {
- return 'DROP DATABASE ' . $name;
- }
-
- /**
- * {@inheritDoc}
- */
- protected function _getCreateTableSQL($tableName, array $columns, array $options = [])
- {
- $queryFields = $this->getColumnDeclarationListSQL($columns);
-
- if (isset($options['uniqueConstraints']) && ! empty($options['uniqueConstraints'])) {
- foreach ($options['uniqueConstraints'] as $index => $definition) {
- $queryFields .= ', ' . $this->getUniqueConstraintDeclarationSQL($index, $definition);
- }
- }
-
- // add all indexes
- if (isset($options['indexes']) && ! empty($options['indexes'])) {
- foreach ($options['indexes'] as $index => $definition) {
- $queryFields .= ', ' . $this->getIndexDeclarationSQL($index, $definition);
- }
- }
-
- // attach all primary keys
- if (isset($options['primary']) && ! empty($options['primary'])) {
- $keyColumns = array_unique(array_values($options['primary']));
- $queryFields .= ', PRIMARY KEY(' . implode(', ', $keyColumns) . ')';
- }
-
- $query = 'CREATE ';
-
- if (!empty($options['temporary'])) {
- $query .= 'TEMPORARY ';
- }
-
- $query .= 'TABLE ' . $tableName . ' (' . $queryFields . ') ';
- $query .= $this->buildTableOptions($options);
- $query .= $this->buildPartitionOptions($options);
-
- $sql[] = $query;
-
- if (isset($options['foreignKeys'])) {
- foreach ((array) $options['foreignKeys'] as $definition) {
- $sql[] = $this->getCreateForeignKeySQL($definition, $tableName);
- }
- }
-
- return $sql;
- }
-
- /**
- * Build SQL for table options
- *
- * @param array $options
- *
- * @return string
- */
- private function buildTableOptions(array $options)
- {
- if (isset($options['table_options'])) {
- return $options['table_options'];
- }
-
- $tableOptions = [];
-
- // Collate
- if ( ! isset($options['collate'])) {
- $options['collate'] = 'utf8_unicode_ci';
- }
-
- $tableOptions[] = sprintf('COLLATE %s', $options['collate']);
-
- // Engine
- if ( ! isset($options['engine'])) {
- $options['engine'] = 'InnoDB';
- }
-
- $tableOptions[] = sprintf('ENGINE = %s', $options['engine']);
-
- // Auto increment
- if (isset($options['auto_increment'])) {
- $tableOptions[] = sprintf('AUTO_INCREMENT = %s', $options['auto_increment']);
- }
-
- // Comment
- if (isset($options['comment'])) {
- $comment = trim($options['comment'], " '");
-
- $tableOptions[] = sprintf("COMMENT = %s ", $this->quoteStringLiteral($comment));
- }
-
- // Row format
- if (isset($options['row_format'])) {
- $tableOptions[] = sprintf('ROW_FORMAT = %s', $options['row_format']);
- }
-
- return implode(' ', $tableOptions);
- }
-
- /**
- * Build SQL for partition options.
- *
- * @param array $options
- *
- * @return string
- */
- private function buildPartitionOptions(array $options)
- {
- return (isset($options['partition_options']))
- ? ' ' . $options['partition_options']
- : '';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getListDatabasesSQL()
- {
- return "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE CATALOG_NAME='LOCAL'";
- }
-
- /**
- * {@inheritDoc}
- */
- protected function getReservedKeywordsClass()
- {
- return Keywords\DrizzleKeywords::class;
- }
-
- /**
- * {@inheritDoc}
- */
- public function getListTablesSQL()
- {
- return "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE' AND TABLE_SCHEMA=DATABASE()";
- }
-
- /**
- * {@inheritDoc}
- */
- public function getListTableColumnsSQL($table, $database = null)
- {
- if ($database) {
- $database = "'" . $database . "'";
- } else {
- $database = 'DATABASE()';
- }
-
- return "SELECT COLUMN_NAME, DATA_TYPE, COLUMN_COMMENT, IS_NULLABLE, IS_AUTO_INCREMENT, CHARACTER_MAXIMUM_LENGTH, COLUMN_DEFAULT," .
- " NUMERIC_PRECISION, NUMERIC_SCALE, COLLATION_NAME" .
- " FROM DATA_DICTIONARY.COLUMNS" .
- " WHERE TABLE_SCHEMA=" . $database . " AND TABLE_NAME = '" . $table . "'";
- }
-
- /**
- * {@inheritDoc}
- */
- public function getListTableForeignKeysSQL($table, $database = null)
- {
- if ($database) {
- $database = "'" . $database . "'";
- } else {
- $database = 'DATABASE()';
- }
-
- return "SELECT CONSTRAINT_NAME, CONSTRAINT_COLUMNS, REFERENCED_TABLE_NAME, REFERENCED_TABLE_COLUMNS, UPDATE_RULE, DELETE_RULE" .
- " FROM DATA_DICTIONARY.FOREIGN_KEYS" .
- " WHERE CONSTRAINT_SCHEMA=" . $database . " AND CONSTRAINT_TABLE='" . $table . "'";
- }
-
- /**
- * {@inheritDoc}
- */
- public function getListTableIndexesSQL($table, $database = null)
- {
- if ($database) {
- $database = "'" . $database . "'";
- } else {
- $database = 'DATABASE()';
- }
-
- return "SELECT INDEX_NAME AS 'key_name', COLUMN_NAME AS 'column_name', IS_USED_IN_PRIMARY AS 'primary', IS_UNIQUE=0 AS 'non_unique'" .
- " FROM DATA_DICTIONARY.INDEX_PARTS" .
- " WHERE TABLE_SCHEMA=" . $database . " AND TABLE_NAME='" . $table . "'";
- }
-
- /**
- * {@inheritDoc}
- */
- public function prefersIdentityColumns()
- {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public function supportsIdentityColumns()
- {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public function supportsInlineColumnComments()
- {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public function supportsViews()
- {
- return false;
- }
-
- /**
- * {@inheritdoc}
- */
- public function supportsColumnCollation()
- {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public function getDropIndexSQL($index, $table=null)
- {
- if ($index instanceof Index) {
- $indexName = $index->getQuotedName($this);
- } elseif (is_string($index)) {
- $indexName = $index;
- } else {
- throw new \InvalidArgumentException('DrizzlePlatform::getDropIndexSQL() expects $index parameter to be string or \Doctrine\DBAL\Schema\Index.');
- }
-
- if ($table instanceof Table) {
- $table = $table->getQuotedName($this);
- } elseif (!is_string($table)) {
- throw new \InvalidArgumentException('DrizzlePlatform::getDropIndexSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.');
- }
-
- if ($index instanceof Index && $index->isPrimary()) {
- // drizzle primary keys are always named "PRIMARY",
- // so we cannot use them in statements because of them being keyword.
- return $this->getDropPrimaryKeySQL($table);
- }
-
- return 'DROP INDEX ' . $indexName . ' ON ' . $table;
- }
-
- /**
- * {@inheritDoc}
- */
- protected function getDropPrimaryKeySQL($table)
- {
- return 'ALTER TABLE ' . $table . ' DROP PRIMARY KEY';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
- {
- if (isset($fieldDeclaration['version']) && $fieldDeclaration['version'] == true) {
- return 'TIMESTAMP';
- }
-
- return 'DATETIME';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
- {
- return 'TIME';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getDateTypeDeclarationSQL(array $fieldDeclaration)
- {
- return 'DATE';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getAlterTableSQL(TableDiff $diff)
- {
- $columnSql = [];
- $queryParts = [];
-
- if ($diff->newName !== false) {
- $queryParts[] = 'RENAME TO ' . $diff->getNewName()->getQuotedName($this);
- }
-
- foreach ($diff->addedColumns as $column) {
- if ($this->onSchemaAlterTableAddColumn($column, $diff, $columnSql)) {
- continue;
- }
-
- $columnArray = $column->toArray();
- $columnArray['comment'] = $this->getColumnComment($column);
- $queryParts[] = 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray);
- }
-
- foreach ($diff->removedColumns as $column) {
- if ($this->onSchemaAlterTableRemoveColumn($column, $diff, $columnSql)) {
- continue;
- }
-
- $queryParts[] = 'DROP ' . $column->getQuotedName($this);
- }
-
- foreach ($diff->changedColumns as $columnDiff) {
- if ($this->onSchemaAlterTableChangeColumn($columnDiff, $diff, $columnSql)) {
- continue;
- }
-
- /* @var $columnDiff \Doctrine\DBAL\Schema\ColumnDiff */
- $column = $columnDiff->column;
- $columnArray = $column->toArray();
-
- // Do not generate column alteration clause if type is binary and only fixed property has changed.
- // Drizzle only supports binary type columns with variable length.
- // Avoids unnecessary table alteration statements.
- if ($columnArray['type'] instanceof BinaryType &&
- $columnDiff->hasChanged('fixed') &&
- count($columnDiff->changedProperties) === 1
- ) {
- continue;
- }
-
- $columnArray['comment'] = $this->getColumnComment($column);
- $queryParts[] = 'CHANGE ' . ($columnDiff->getOldColumnName()->getQuotedName($this)) . ' '
- . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray);
- }
-
- foreach ($diff->renamedColumns as $oldColumnName => $column) {
- if ($this->onSchemaAlterTableRenameColumn($oldColumnName, $column, $diff, $columnSql)) {
- continue;
- }
-
- $oldColumnName = new Identifier($oldColumnName);
-
- $columnArray = $column->toArray();
- $columnArray['comment'] = $this->getColumnComment($column);
- $queryParts[] = 'CHANGE ' . $oldColumnName->getQuotedName($this) . ' '
- . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray);
- }
-
- $sql = [];
- $tableSql = [];
-
- if ( ! $this->onSchemaAlterTable($diff, $tableSql)) {
- if (count($queryParts) > 0) {
- $sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' ' . implode(", ", $queryParts);
- }
- $sql = array_merge(
- $this->getPreAlterTableIndexForeignKeySQL($diff),
- $sql,
- $this->getPostAlterTableIndexForeignKeySQL($diff)
- );
- }
-
- return array_merge($sql, $tableSql, $columnSql);
- }
-
- /**
- * {@inheritDoc}
- */
- public function getDropTemporaryTableSQL($table)
- {
- if ($table instanceof Table) {
- $table = $table->getQuotedName($this);
- } elseif (!is_string($table)) {
- throw new \InvalidArgumentException('getDropTableSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.');
- }
-
- return 'DROP TEMPORARY TABLE ' . $table;
- }
-
- /**
- * {@inheritDoc}
- */
- public function convertBooleans($item)
- {
- if (is_array($item)) {
- foreach ($item as $key => $value) {
- if (is_bool($value) || is_numeric($item)) {
- $item[$key] = ($value) ? 'true' : 'false';
- }
- }
- } elseif (is_bool($item) || is_numeric($item)) {
- $item = ($item) ? 'true' : 'false';
- }
-
- return $item;
- }
-
- /**
- * {@inheritDoc}
- */
- public function getLocateExpression($str, $substr, $startPos = false)
- {
- if ($startPos == false) {
- return 'LOCATE(' . $substr . ', ' . $str . ')';
- }
-
- return 'LOCATE(' . $substr . ', ' . $str . ', '.$startPos.')';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getGuidExpression()
- {
- return 'UUID()';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getRegexpExpression()
- {
- return 'RLIKE';
- }
-}
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/DB2Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/DB2Keywords.php
index 884cc8ec775..cb055df6689 100644
--- a/lib/Doctrine/DBAL/Platforms/Keywords/DB2Keywords.php
+++ b/lib/Doctrine/DBAL/Platforms/Keywords/DB2Keywords.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms\Keywords;
@@ -48,24 +31,6 @@ protected function getKeywords()
'ALIAS',
'ALL',
'ALLOCATE',
- 'DOCUMENT',
- 'DOUBLE',
- 'DROP',
- 'DSSIZE',
- 'DYNAMIC',
- 'EACH',
- 'LOCK',
- 'LOCKMAX',
- 'LOCKSIZE',
- 'LONG',
- 'LOOP',
- 'MAINTAINED',
- 'ROUND_CEILING',
- 'ROUND_DOWN',
- 'ROUND_FLOOR',
- 'ROUND_HALF_DOWN',
- 'ROUND_HALF_EVEN',
- 'ROUND_HALF_UP',
'ALLOW',
'ALTER',
'AND',
@@ -133,6 +98,38 @@ protected function getKeywords()
'DATABASE',
'DATAPARTITIONNAME',
'DATAPARTITIONNUM',
+ 'DATE',
+ 'DAY',
+ 'DAYS',
+ 'DB2GENERAL',
+ 'DB2GENRL',
+ 'DB2SQL',
+ 'DBINFO',
+ 'DBPARTITIONNAME',
+ 'DBPARTITIONNUM',
+ 'DEALLOCATE',
+ 'DECLARE',
+ 'DEFAULT',
+ 'DEFAULTS',
+ 'DEFINITION',
+ 'DELETE',
+ 'DENSE_RANK',
+ 'DENSERANK',
+ 'DESCRIBE',
+ 'DESCRIPTOR',
+ 'DETERMINISTIC',
+ 'DIAGNOSTICS',
+ 'DISABLE',
+ 'DISALLOW',
+ 'DISCONNECT',
+ 'DISTINCT',
+ 'DO',
+ 'DOCUMENT',
+ 'DOUBLE',
+ 'DROP',
+ 'DSSIZE',
+ 'DYNAMIC',
+ 'EACH',
'EDITPROC',
'ELSE',
'ELSEIF',
@@ -200,6 +197,38 @@ protected function getKeywords()
'INSENSITIVE',
'INSERT',
'INTEGRITY',
+ 'INTERSECT',
+ 'INTO',
+ 'IS',
+ 'ISOBID',
+ 'ISOLATION',
+ 'ITERATE',
+ 'JAR',
+ 'JAVA',
+ 'JOIN',
+ 'KEEP',
+ 'KEY',
+ 'LABEL',
+ 'LANGUAGE',
+ 'LATERAL',
+ 'LC_CTYPE',
+ 'LEAVE',
+ 'LEFT',
+ 'LIKE',
+ 'LINKTYPE',
+ 'LOCAL',
+ 'LOCALDATE',
+ 'LOCALE',
+ 'LOCALTIME',
+ 'LOCALTIMESTAMP RIGHT',
+ 'LOCATOR',
+ 'LOCATORS',
+ 'LOCK',
+ 'LOCKMAX',
+ 'LOCKSIZE',
+ 'LONG',
+ 'LOOP',
+ 'MAINTAINED',
'MATERIALIZED',
'MAXVALUE',
'MICROSECOND',
@@ -267,6 +296,37 @@ protected function getKeywords()
'PROCEDURE',
'PROGRAM',
'PSID',
+ 'PUBLIC',
+ 'QUERY',
+ 'QUERYNO',
+ 'RANGE',
+ 'RANK',
+ 'READ',
+ 'READS',
+ 'RECOVERY',
+ 'REFERENCES',
+ 'REFERENCING',
+ 'REFRESH',
+ 'RELEASE',
+ 'RENAME',
+ 'REPEAT',
+ 'RESET',
+ 'RESIGNAL',
+ 'RESTART',
+ 'RESTRICT',
+ 'RESULT',
+ 'RESULT_SET_LOCATOR WLM',
+ 'RETURN',
+ 'RETURNS',
+ 'REVOKE',
+ 'ROLE',
+ 'ROLLBACK',
+ 'ROUND_CEILING',
+ 'ROUND_DOWN',
+ 'ROUND_FLOOR',
+ 'ROUND_HALF_DOWN',
+ 'ROUND_HALF_EVEN',
+ 'ROUND_HALF_UP',
'ROUND_UP',
'ROUTINE',
'ROW',
@@ -334,107 +394,30 @@ protected function getKeywords()
'UNIQUE',
'UNTIL',
'UPDATE',
- 'DATE',
- 'DAY',
- 'DAYS',
- 'DB2GENERAL',
- 'DB2GENRL',
- 'DB2SQL',
- 'DBINFO',
- 'DBPARTITIONNAME',
- 'DBPARTITIONNUM',
- 'DEALLOCATE',
- 'DECLARE',
- 'DEFAULT',
- 'DEFAULTS',
- 'DEFINITION',
- 'DELETE',
- 'DENSE_RANK',
- 'DENSERANK',
- 'DESCRIBE',
- 'DESCRIPTOR',
- 'DETERMINISTIC',
- 'DIAGNOSTICS',
- 'DISABLE',
- 'DISALLOW',
- 'DISCONNECT',
- 'DISTINCT',
- 'DO',
- 'INTERSECT',
- 'PUBLIC',
'USAGE',
- 'INTO',
- 'QUERY',
'USER',
- 'IS',
- 'QUERYNO',
'USING',
- 'ISOBID',
- 'RANGE',
'VALIDPROC',
- 'ISOLATION',
- 'RANK',
'VALUE',
- 'ITERATE',
- 'READ',
'VALUES',
- 'JAR',
- 'READS',
'VARIABLE',
- 'JAVA',
- 'RECOVERY',
'VARIANT',
- 'JOIN',
- 'REFERENCES',
'VCAT',
- 'KEEP',
- 'REFERENCING',
'VERSION',
- 'KEY',
- 'REFRESH',
'VIEW',
- 'LABEL',
- 'RELEASE',
'VOLATILE',
- 'LANGUAGE',
- 'RENAME',
'VOLUMES',
- 'LATERAL',
- 'REPEAT',
'WHEN',
- 'LC_CTYPE',
- 'RESET',
'WHENEVER',
- 'LEAVE',
- 'RESIGNAL',
'WHERE',
- 'LEFT',
- 'RESTART',
'WHILE',
- 'LIKE',
- 'RESTRICT',
'WITH',
- 'LINKTYPE',
- 'RESULT',
'WITHOUT',
- 'LOCAL',
- 'RESULT_SET_LOCATOR WLM',
- 'LOCALDATE',
- 'RETURN',
'WRITE',
- 'LOCALE',
- 'RETURNS',
'XMLELEMENT',
- 'LOCALTIME',
- 'REVOKE',
'XMLEXISTS',
- 'LOCALTIMESTAMP RIGHT',
'XMLNAMESPACES',
- 'LOCATOR',
- 'ROLE',
'YEAR',
- 'LOCATORS',
- 'ROLLBACK',
'YEARS',
];
}
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/DrizzleKeywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/DrizzleKeywords.php
deleted file mode 100644
index 46c8b246339..00000000000
--- a/lib/Doctrine/DBAL/Platforms/Keywords/DrizzleKeywords.php
+++ /dev/null
@@ -1,345 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Platforms\Keywords;
-
-/**
- * Drizzle Keywordlist.
- *
- * @author Kim Hemsø Rasmussen
- */
-class DrizzleKeywords extends KeywordList
-{
- /**
- * {@inheritdoc}
- */
- public function getName()
- {
- return 'drizzle';
- }
-
- /**
- * {@inheritdoc}
- */
- protected function getKeywords()
- {
- return [
- 'ABS',
- 'ALL',
- 'ALLOCATE',
- 'ALTER',
- 'AND',
- 'ANY',
- 'ARE',
- 'ARRAY',
- 'AS',
- 'ASENSITIVE',
- 'ASYMMETRIC',
- 'AT',
- 'ATOMIC',
- 'AUTHORIZATION',
- 'AVG',
- 'BEGIN',
- 'BETWEEN',
- 'BIGINT',
- 'BINARY',
- 'BLOB',
- 'BOOLEAN',
- 'BOTH',
- 'BY',
- 'CALL',
- 'CALLED',
- 'CARDINALITY',
- 'CASCADED',
- 'CASE',
- 'CAST',
- 'CEIL',
- 'CEILING',
- 'CHAR',
- 'CHARACTER',
- 'CHARACTER_LENGTH',
- 'CHAR_LENGTH',
- 'CHECK',
- 'CLOB',
- 'CLOSE',
- 'COALESCE',
- 'COLLATE',
- 'COLLECT',
- 'COLUMN',
- 'COMMIT',
- 'CONDITION',
- 'CONNECT',
- 'CONSTRAINT',
- 'CONVERT',
- 'CORR',
- 'CORRESPONDING',
- 'COUNT',
- 'COVAR_POP',
- 'COVAR_SAMP',
- 'CREATE',
- 'CROSS',
- 'CUBE',
- 'CUME_DIST',
- 'CURRENT',
- 'CURRENT_DATE',
- 'CURRENT_DEFAULT_TRANSFORM_GROUP',
- 'CURRENT_PATH',
- 'CURRENT_ROLE',
- 'CURRENT_TIME',
- 'CURRENT_TIMESTAMP',
- 'CURRENT_TRANSFORM_GROUP_FOR_TYPE',
- 'CURRENT_USER',
- 'CURSOR',
- 'CYCLE',
- 'DATE',
- 'DAY',
- 'DEALLOCATE',
- 'DEC',
- 'DECIMAL',
- 'DECLARE',
- 'DEFAULT',
- 'DELETE',
- 'DENSE_RANK',
- 'DEREF',
- 'DESCRIBE',
- 'DETERMINISTIC',
- 'DISCONNECT',
- 'DISTINCT',
- 'DOUBLE',
- 'DROP',
- 'DYNAMIC',
- 'EACH',
- 'ELEMENT',
- 'ELSE',
- 'END',
- 'ESCAPE',
- 'EVERY',
- 'EXCEPT',
- 'EXEC',
- 'EXECUTE',
- 'EXISTS',
- 'EXP',
- 'EXTERNAL',
- 'EXTRACT',
- 'FALSE',
- 'FETCH',
- 'FILTER',
- 'FLOAT',
- 'FLOOR',
- 'FOR',
- 'FOREIGN',
- 'FREE',
- 'FROM',
- 'FULL',
- 'FUNCTION',
- 'FUSION',
- 'GET',
- 'GLOBAL',
- 'GRANT',
- 'GROUP',
- 'GROUPING',
- 'HAVING',
- 'HOLD',
- 'HOUR',
- 'IDENTITY',
- 'IN',
- 'INDICATOR',
- 'INNER',
- 'INOUT',
- 'INSENSITIVE',
- 'INSERT',
- 'INT',
- 'INTEGER',
- 'INTERSECT',
- 'INTERSECTION',
- 'INTERVAL',
- 'INTO',
- 'IS',
- 'JOIN',
- 'LANGUAGE',
- 'LARGE',
- 'LATERAL',
- 'LEADING',
- 'LEFT',
- 'LIKE',
- 'LN',
- 'LOCAL',
- 'LOCALTIME',
- 'LOCALTIMESTAMP',
- 'LOWER',
- 'MATCH',
- 'MAX',
- 'MEMBER',
- 'MERGE',
- 'METHOD',
- 'MIN',
- 'MINUTE',
- 'MOD',
- 'MODIFIES',
- 'MODULE',
- 'MONTH',
- 'MULTISET',
- 'NATIONAL',
- 'NATURAL',
- 'NCHAR',
- 'NCLOB',
- 'NEW',
- 'NO',
- 'NONE',
- 'NORMALIZE',
- 'NOT',
- 'NULL_SYM',
- 'NULLIF',
- 'NUMERIC',
- 'OCTET_LENGTH',
- 'OF',
- 'OLD',
- 'ON',
- 'ONLY',
- 'OPEN',
- 'OR',
- 'ORDER',
- 'OUT',
- 'OUTER',
- 'OVER',
- 'OVERLAPS',
- 'OVERLAY',
- 'PARAMETER',
- 'PARTITION',
- 'PERCENTILE_CONT',
- 'PERCENTILE_DISC',
- 'PERCENT_RANK',
- 'POSITION',
- 'POWER',
- 'PRECISION',
- 'PREPARE',
- 'PRIMARY',
- 'PROCEDURE',
- 'RANGE',
- 'RANK',
- 'READS',
- 'REAL',
- 'RECURSIVE',
- 'REF',
- 'REFERENCES',
- 'REFERENCING',
- 'REGR_AVGX',
- 'REGR_AVGY',
- 'REGR_COUNT',
- 'REGR_INTERCEPT',
- 'REGR_R2',
- 'REGR_SLOPE',
- 'REGR_SXX',
- 'REGR_SXY',
- 'REGR_SYY',
- 'RELEASE',
- 'RESULT',
- 'RETURN',
- 'RETURNS',
- 'REVOKE',
- 'RIGHT',
- 'ROLLBACK',
- 'ROLLUP',
- 'ROW',
- 'ROWS',
- 'ROW_NUMBER',
- 'SAVEPOINT',
- 'SCOPE',
- 'SCROLL',
- 'SEARCH',
- 'SECOND',
- 'SELECT',
- 'SENSITIVE',
- 'SESSION_USER',
- 'SET',
- 'SIMILAR',
- 'SMALLINT',
- 'SOME',
- 'SPECIFIC',
- 'SPECIFICTYPE',
- 'SQL',
- 'SQLEXCEPTION',
- 'SQLSTATE',
- 'SQLWARNING',
- 'SQRT',
- 'START',
- 'STATIC',
- 'STDDEV_POP',
- 'STDDEV_SAMP',
- 'SUBMULTISET',
- 'SUBSTRING',
- 'SUM',
- 'SYMMETRIC',
- 'SYSTEM',
- 'SYSTEM_USER',
- 'TABLE',
- 'TABLESAMPLE',
- 'THEN',
- 'TIME',
- 'TIMESTAMP',
- 'TIMEZONE_HOUR',
- 'TIMEZONE_MINUTE',
- 'TO',
- 'TRAILING',
- 'TRANSLATE',
- 'TRANSLATION',
- 'TREAT',
- 'TRIGGER',
- 'TRIM',
- 'TRUE',
- 'UESCAPE',
- 'UNION',
- 'UNIQUE',
- 'UNKNOWN',
- 'UNNEST',
- 'UPDATE',
- 'UPPER',
- 'USER',
- 'USING',
- 'VALUE',
- 'VALUES',
- 'VARCHAR',
- 'VARYING',
- 'VAR_POP',
- 'VAR_SAMP',
- 'WHEN',
- 'WHENEVER',
- 'WHERE',
- 'WIDTH_BUCKET',
- 'WINDOW',
- 'WITH',
- 'WITHIN',
- 'WITHOUT',
- 'XML',
- 'XMLAGG',
- 'XMLATTRIBUTES',
- 'XMLBINARY',
- 'XMLCOMMENT',
- 'XMLCONCAT',
- 'XMLELEMENT',
- 'XMLFOREST',
- 'XMLNAMESPACES',
- 'XMLPARSE',
- 'XMLPI',
- 'XMLROOT',
- 'XMLSERIALIZE',
- 'YEAR',
- ];
- }
-}
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php b/lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php
index e8933a3860d..66b69f32331 100644
--- a/lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php
+++ b/lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms\Keywords;
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php
deleted file mode 100644
index 9c8f614993a..00000000000
--- a/lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php
+++ /dev/null
@@ -1,43 +0,0 @@
-.
- */
-
-
-namespace Doctrine\DBAL\Platforms\Keywords;
-
-/**
- * MsSQL Keywordlist
- *
- * @license BSD http://www.opensource.org/licenses/bsd-license.php
- * @link www.doctrine-project.com
- * @since 2.0
- * @author Benjamin Eberlei
- * @author David Coallier
- * @author Steve Müller
- * @deprecated Use SQLServerKeywords class instead.
- */
-class MsSQLKeywords extends SQLServerKeywords
-{
- /**
- * {@inheritdoc}
- */
- public function getName()
- {
- return 'MsSQL';
- }
-}
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/MySQL57Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/MySQL57Keywords.php
index ef7c389ed3a..44a04e5d94a 100644
--- a/lib/Doctrine/DBAL/Platforms/Keywords/MySQL57Keywords.php
+++ b/lib/Doctrine/DBAL/Platforms/Keywords/MySQL57Keywords.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms\Keywords;
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/MySQLKeywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/MySQLKeywords.php
index 8ba9b4d74ac..b6fd123b39d 100644
--- a/lib/Doctrine/DBAL/Platforms/Keywords/MySQLKeywords.php
+++ b/lib/Doctrine/DBAL/Platforms/Keywords/MySQLKeywords.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms\Keywords;
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/OracleKeywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/OracleKeywords.php
index 4914d2e9db4..c0d5d1ed226 100644
--- a/lib/Doctrine/DBAL/Platforms/Keywords/OracleKeywords.php
+++ b/lib/Doctrine/DBAL/Platforms/Keywords/OracleKeywords.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms\Keywords;
@@ -44,118 +27,118 @@ protected function getKeywords()
{
return [
'ACCESS',
- 'ELSE',
- 'MODIFY',
- 'START',
'ADD',
- 'EXCLUSIVE',
- 'NOAUDIT',
- 'SELECT',
'ALL',
- 'EXISTS',
- 'NOCOMPRESS',
- 'SESSION',
'ALTER',
- 'FILE',
- 'NOT',
- 'SET',
'AND',
- 'FLOAT',
- 'NOTFOUND ',
- 'SHARE',
'ANY',
- 'FOR',
- 'NOWAIT',
- 'SIZE',
'ARRAYLEN',
- 'FROM',
- 'NULL',
- 'SMALLINT',
'AS',
- 'GRANT',
- 'NUMBER',
- 'SQLBUF',
'ASC',
- 'GROUP',
- 'OF',
- 'SUCCESSFUL',
'AUDIT',
- 'HAVING',
- 'OFFLINE ',
- 'SYNONYM',
'BETWEEN',
- 'IDENTIFIED',
- 'ON',
- 'SYSDATE',
'BY',
- 'IMMEDIATE',
- 'ONLINE',
- 'TABLE',
'CHAR',
- 'IN',
- 'OPTION',
- 'THEN',
'CHECK',
- 'INCREMENT',
- 'OR',
- 'TO',
'CLUSTER',
- 'INDEX',
- 'ORDER',
- 'TRIGGER',
'COLUMN',
- 'INITIAL',
- 'PCTFREE',
- 'UID',
'COMMENT',
- 'INSERT',
- 'PRIOR',
- 'UNION',
'COMPRESS',
- 'INTEGER',
- 'PRIVILEGES',
- 'UNIQUE',
'CONNECT',
- 'INTERSECT',
- 'PUBLIC',
- 'UPDATE',
'CREATE',
- 'INTO',
- 'RAW',
- 'USER',
'CURRENT',
- 'IS',
- 'RENAME',
- 'VALIDATE',
'DATE',
- 'LEVEL',
- 'RESOURCE',
- 'VALUES',
'DECIMAL',
- 'LIKE',
- 'REVOKE',
- 'VARCHAR',
'DEFAULT',
- 'LOCK',
- 'ROW',
- 'VARCHAR2',
'DELETE',
- 'LONG',
- 'ROWID',
- 'VIEW',
'DESC',
- 'MAXEXTENTS',
- 'ROWLABEL',
- 'WHENEVER',
'DISTINCT',
- 'MINUS',
- 'ROWNUM',
- 'WHERE',
'DROP',
+ 'ELSE',
+ 'EXCLUSIVE',
+ 'EXISTS',
+ 'FILE',
+ 'FLOAT',
+ 'FOR',
+ 'FROM',
+ 'GRANT',
+ 'GROUP',
+ 'HAVING',
+ 'IDENTIFIED',
+ 'IMMEDIATE',
+ 'IN',
+ 'INCREMENT',
+ 'INDEX',
+ 'INITIAL',
+ 'INSERT',
+ 'INTEGER',
+ 'INTERSECT',
+ 'INTO',
+ 'IS',
+ 'LEVEL',
+ 'LIKE',
+ 'LOCK',
+ 'LONG',
+ 'MAXEXTENTS',
+ 'MINUS',
'MODE',
+ 'MODIFY',
+ 'NOAUDIT',
+ 'NOCOMPRESS',
+ 'NOT',
+ 'NOTFOUND',
+ 'NOWAIT',
+ 'NULL',
+ 'NUMBER',
+ 'OF',
+ 'OFFLINE',
+ 'ON',
+ 'ONLINE',
+ 'OPTION',
+ 'OR',
+ 'ORDER',
+ 'PCTFREE',
+ 'PRIOR',
+ 'PRIVILEGES',
+ 'PUBLIC',
+ 'RANGE',
+ 'RAW',
+ 'RENAME',
+ 'RESOURCE',
+ 'REVOKE',
+ 'ROW',
+ 'ROWID',
+ 'ROWLABEL',
+ 'ROWNUM',
'ROWS',
+ 'SELECT',
+ 'SESSION',
+ 'SET',
+ 'SHARE',
+ 'SIZE',
+ 'SMALLINT',
+ 'SQLBUF',
+ 'START',
+ 'SUCCESSFUL',
+ 'SYNONYM',
+ 'SYSDATE',
+ 'TABLE',
+ 'THEN',
+ 'TO',
+ 'TRIGGER',
+ 'UID',
+ 'UNION',
+ 'UNIQUE',
+ 'UPDATE',
+ 'USER',
+ 'VALIDATE',
+ 'VALUES',
+ 'VARCHAR',
+ 'VARCHAR2',
+ 'VIEW',
+ 'WHENEVER',
+ 'WHERE',
'WITH',
- 'RANGE',
];
}
}
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL91Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL91Keywords.php
deleted file mode 100644
index ecbd0a46db0..00000000000
--- a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL91Keywords.php
+++ /dev/null
@@ -1,148 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Platforms\Keywords;
-
-/**
- * PostgreSQL 9.1 reserved keywords list.
- *
- * @author Martin Hasoň
- * @author Steve Müller
- * @link www.doctrine-project.org
- * @since 2.5
- */
-class PostgreSQL91Keywords extends PostgreSQLKeywords
-{
- /**
- * {@inheritdoc}
- */
- public function getName()
- {
- return 'PostgreSQL91';
- }
-
- /**
- * {@inheritdoc}
- *
- * @link http://www.postgresql.org/docs/9.1/static/sql-keywords-appendix.html
- */
- protected function getKeywords()
- {
- return [
- 'ALL',
- 'ANALYSE',
- 'ANALYZE',
- 'AND',
- 'ANY',
- 'ARRAY',
- 'AS',
- 'ASC',
- 'ASYMMETRIC',
- 'AUTHORIZATION',
- 'BINARY',
- 'BOTH',
- 'CASE',
- 'CAST',
- 'CHECK',
- 'COLLATE',
- 'COLUMN',
- 'CONCURRENTLY',
- 'CONSTRAINT',
- 'CREATE',
- 'CROSS',
- 'CURRENT_CATALOG',
- 'CURRENT_DATE',
- 'CURRENT_ROLE',
- 'CURRENT_SCHEMA',
- 'CURRENT_TIME',
- 'CURRENT_TIMESTAMP',
- 'CURRENT_USER',
- 'DEFAULT',
- 'DEFERRABLE',
- 'DESC',
- 'DISTINCT',
- 'DO',
- 'ELSE',
- 'END',
- 'EXCEPT',
- 'FALSE',
- 'FETCH',
- 'FOR',
- 'FOREIGN',
- 'FREEZE',
- 'FROM',
- 'FULL',
- 'GRANT',
- 'GROUP',
- 'HAVING',
- 'ILIKE',
- 'IN',
- 'INITIALLY',
- 'INNER',
- 'INTERSECT',
- 'INTO',
- 'IS',
- 'ISNULL',
- 'JOIN',
- 'LEADING',
- 'LEFT',
- 'LIKE',
- 'LIMIT',
- 'LOCALTIME',
- 'LOCALTIMESTAMP',
- 'NATURAL',
- 'NOT',
- 'NOTNULL',
- 'NULL',
- 'OFFSET',
- 'ON',
- 'ONLY',
- 'OR',
- 'ORDER',
- 'OUTER',
- 'OVER',
- 'OVERLAPS',
- 'PLACING',
- 'PRIMARY',
- 'REFERENCES',
- 'RETURNING',
- 'RIGHT',
- 'SELECT',
- 'SESSION_USER',
- 'SIMILAR',
- 'SOME',
- 'SYMMETRIC',
- 'TABLE',
- 'THEN',
- 'TO',
- 'TRAILING',
- 'TRUE',
- 'UNION',
- 'UNIQUE',
- 'USER',
- 'USING',
- 'VARIADIC',
- 'VERBOSE',
- 'WHEN',
- 'WHERE',
- 'WINDOW',
- 'WITH',
- ];
- }
-}
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL92Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL92Keywords.php
deleted file mode 100644
index d6c6a9d3f77..00000000000
--- a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL92Keywords.php
+++ /dev/null
@@ -1,52 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Platforms\Keywords;
-
-use function array_merge;
-
-/**
- * PostgreSQL 9.2 reserved keywords list.
- *
- * @author Steve Müller
- * @link www.doctrine-project.org
- * @since 2.5
- */
-class PostgreSQL92Keywords extends PostgreSQL91Keywords
-{
- /**
- * {@inheritdoc}
- */
- public function getName()
- {
- return 'PostgreSQL92';
- }
-
- /**
- * {@inheritdoc}
- *
- * @link http://www.postgresql.org/docs/9.2/static/sql-keywords-appendix.html
- */
- protected function getKeywords()
- {
- return array_merge(parent::getKeywords(), [
- 'COLLATION',
- ]);
- }
-}
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL94Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL94Keywords.php
index 8daa59539a4..9f93071f0b6 100644
--- a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL94Keywords.php
+++ b/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL94Keywords.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms\Keywords;
@@ -29,7 +12,7 @@
* @link www.doctrine-project.org
* @since 2.6
*/
-class PostgreSQL94Keywords extends PostgreSQL92Keywords
+class PostgreSQL94Keywords extends PostgreSQLKeywords
{
/**
* {@inheritdoc}
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQLKeywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQLKeywords.php
index 571d6f4e818..7d0ba4e7584 100644
--- a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQLKeywords.php
+++ b/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQLKeywords.php
@@ -1,26 +1,9 @@
.
- */
namespace Doctrine\DBAL\Platforms\Keywords;
/**
- * PostgreSQL Keywordlist.
+ * PostgreSQL 9.3 keywords list.
*
* @link www.doctrine-project.org
* @since 2.0
@@ -48,20 +31,27 @@ protected function getKeywords()
'ANALYZE',
'AND',
'ANY',
+ 'ARRAY',
'AS',
'ASC',
+ 'ASYMMETRIC',
'AUTHORIZATION',
- 'BETWEEN',
'BINARY',
'BOTH',
'CASE',
'CAST',
'CHECK',
'COLLATE',
+ 'COLLATION',
'COLUMN',
+ 'CONCURRENTLY',
'CONSTRAINT',
'CREATE',
+ 'CROSS',
+ 'CURRENT_CATALOG',
'CURRENT_DATE',
+ 'CURRENT_ROLE',
+ 'CURRENT_SCHEMA',
'CURRENT_TIME',
'CURRENT_TIMESTAMP',
'CURRENT_USER',
@@ -74,6 +64,7 @@ protected function getKeywords()
'END',
'EXCEPT',
'FALSE',
+ 'FETCH',
'FOR',
'FOREIGN',
'FREEZE',
@@ -98,26 +89,27 @@ protected function getKeywords()
'LOCALTIME',
'LOCALTIMESTAMP',
'NATURAL',
- 'NEW',
'NOT',
'NOTNULL',
'NULL',
- 'OFF',
'OFFSET',
- 'OLD',
'ON',
'ONLY',
'OR',
'ORDER',
'OUTER',
+ 'OVER',
'OVERLAPS',
'PLACING',
'PRIMARY',
'REFERENCES',
+ 'RETURNING',
+ 'RIGHT',
'SELECT',
'SESSION_USER',
'SIMILAR',
'SOME',
+ 'SYMMETRIC',
'TABLE',
'THEN',
'TO',
@@ -127,9 +119,12 @@ protected function getKeywords()
'UNIQUE',
'USER',
'USING',
+ 'VARIADIC',
'VERBOSE',
'WHEN',
- 'WHERE'
+ 'WHERE',
+ 'WINDOW',
+ 'WITH',
];
}
}
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/ReservedKeywordsValidator.php b/lib/Doctrine/DBAL/Platforms/Keywords/ReservedKeywordsValidator.php
index c6a5954e274..b8060967431 100644
--- a/lib/Doctrine/DBAL/Platforms/Keywords/ReservedKeywordsValidator.php
+++ b/lib/Doctrine/DBAL/Platforms/Keywords/ReservedKeywordsValidator.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms\Keywords;
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere11Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere11Keywords.php
deleted file mode 100644
index 6e67ee2e6fa..00000000000
--- a/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere11Keywords.php
+++ /dev/null
@@ -1,58 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Platforms\Keywords;
-
-use function array_diff;
-use function array_merge;
-
-/**
- * SAP Sybase SQL Anywhere 11 reserved keywords list.
- *
- * @author Steve Müller
- */
-class SQLAnywhere11Keywords extends SQLAnywhereKeywords
-{
- /**
- * {@inheritdoc}
- */
- public function getName()
- {
- return 'SQLAnywhere11';
- }
-
- /**
- * {@inheritdoc}
- *
- * @link http://dcx.sybase.com/1100/en/dbreference_en11/alhakeywords.html
- */
- protected function getKeywords()
- {
- return array_merge(
- array_diff(
- parent::getKeywords(),
- ['IQ']
- ),
- [
- 'MERGE',
- 'OPENSTRING'
- ]
- );
- }
-}
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere12Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere12Keywords.php
deleted file mode 100644
index ebc38bf8440..00000000000
--- a/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere12Keywords.php
+++ /dev/null
@@ -1,67 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Platforms\Keywords;
-
-use function array_diff;
-use function array_merge;
-
-/**
- * SAP Sybase SQL Anywhere 12 reserved keywords list.
- *
- * @author Steve Müller
- */
-class SQLAnywhere12Keywords extends SQLAnywhere11Keywords
-{
- /**
- * {@inheritdoc}
- */
- public function getName()
- {
- return 'SQLAnywhere12';
- }
-
- /**
- * {@inheritdoc}
- *
- * @link http://dcx.sybase.com/1200/en/dbreference/alhakeywords.html
- */
- protected function getKeywords()
- {
- return array_merge(
- array_diff(
- parent::getKeywords(),
- [
- 'INDEX_LPAREN',
- 'SYNTAX_ERROR',
- 'WITH_CUBE',
- 'WITH_LPAREN',
- 'WITH_ROLLUP'
- ]
- ),
- [
- 'DATETIMEOFFSET',
- 'LIMIT',
- 'OPENXML',
- 'SPATIAL',
- 'TREAT'
- ]
- );
- }
-}
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere16Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere16Keywords.php
deleted file mode 100644
index 1ec984e789c..00000000000
--- a/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere16Keywords.php
+++ /dev/null
@@ -1,58 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Platforms\Keywords;
-
-use function array_merge;
-
-/**
- * SAP Sybase SQL Anywhere 16 reserved keywords list.
- *
- * @author Steve Müller
- */
-class SQLAnywhere16Keywords extends SQLAnywhere12Keywords
-{
- /**
- * {@inheritdoc}
- */
- public function getName()
- {
- return 'SQLAnywhere16';
- }
-
- /**
- * {@inheritdoc}
- *
- * @link http://dcx.sybase.com/index.html#sa160/en/dbreference/alhakeywords.html
- */
- protected function getKeywords()
- {
- return array_merge(
- parent::getKeywords(),
- [
- 'ARRAY',
- 'JSON',
- 'ROW',
- 'ROWTYPE',
- 'UNNEST',
- 'VARRAY'
- ]
- );
- }
-}
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhereKeywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhereKeywords.php
index 9d5ab5db870..342177f4857 100644
--- a/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhereKeywords.php
+++ b/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhereKeywords.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms\Keywords;
@@ -47,6 +30,7 @@ protected function getKeywords()
'ALTER',
'AND',
'ANY',
+ 'ARRAY',
'AS',
'ASC',
'ATTACH',
@@ -87,6 +71,7 @@ protected function getKeywords()
'CURRENT_USER',
'CURSOR',
'DATE',
+ 'DATETIMEOFFSET',
'DBSPACE',
'DEALLOCATE',
'DEC',
@@ -133,7 +118,6 @@ protected function getKeywords()
'IF',
'IN',
'INDEX',
- 'INDEX_LPAREN',
'INNER',
'INOUT',
'INSENSITIVE',
@@ -146,20 +130,22 @@ protected function getKeywords()
'INTEGRATED',
'INTERSECT',
'INTO',
- 'IQ',
'IS',
'ISOLATION',
'JOIN',
+ 'JSON',
'KERBEROS',
'KEY',
'LATERAL',
'LEFT',
'LIKE',
+ 'LIMIT',
'LOCK',
'LOGIN',
'LONG',
'MATCH',
'MEMBERSHIP',
+ 'MERGE',
'MESSAGE',
'MODE',
'MODIFY',
@@ -177,6 +163,8 @@ protected function getKeywords()
'OFF',
'ON',
'OPEN',
+ 'OPENSTRING',
+ 'OPENXML',
'OPTION',
'OPTIONS',
'OR',
@@ -213,6 +201,8 @@ protected function getKeywords()
'RIGHT',
'ROLLBACK',
'ROLLUP',
+ 'ROW',
+ 'ROWTYPE',
'SAVE',
'SAVEPOINT',
'SCROLL',
@@ -224,6 +214,7 @@ protected function getKeywords()
'SHARE',
'SMALLINT',
'SOME',
+ 'SPATIAL',
'SQLCODE',
'SQLSTATE',
'START',
@@ -231,7 +222,6 @@ protected function getKeywords()
'SUBTRANS',
'SUBTRANSACTION',
'SYNCHRONIZE',
- 'SYNTAX_ERROR',
'TABLE',
'TEMPORARY',
'THEN',
@@ -241,6 +231,7 @@ protected function getKeywords()
'TO',
'TOP',
'TRAN',
+ 'TREAT',
'TRIGGER',
'TRUNCATE',
'TSEQUAL',
@@ -249,6 +240,7 @@ protected function getKeywords()
'UNIQUE',
'UNIQUEIDENTIFIER',
'UNKNOWN',
+ 'UNNEST',
'UNSIGNED',
'UPDATE',
'UPDATING',
@@ -260,6 +252,7 @@ protected function getKeywords()
'VARBIT',
'VARCHAR',
'VARIABLE',
+ 'VARRAY',
'VARYING',
'VIEW',
'WAIT',
@@ -269,9 +262,6 @@ protected function getKeywords()
'WHILE',
'WINDOW',
'WITH',
- 'WITH_CUBE',
- 'WITH_LPAREN',
- 'WITH_ROLLUP',
'WITHIN',
'WORK',
'WRITETEXT',
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2005Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2005Keywords.php
deleted file mode 100644
index 02b4656208d..00000000000
--- a/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2005Keywords.php
+++ /dev/null
@@ -1,59 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Platforms\Keywords;
-
-use function array_diff;
-use function array_merge;
-
-/**
- * Microsoft SQL Server 2005 reserved keyword dictionary.
- *
- * @license BSD http://www.opensource.org/licenses/bsd-license.php
- * @link www.doctrine-project.com
- * @since 2.3
- * @author Steve Müller
- */
-class SQLServer2005Keywords extends SQLServerKeywords
-{
- /**
- * {@inheritdoc}
- */
- public function getName()
- {
- return 'SQLServer2005';
- }
-
- /**
- * {@inheritdoc}
- *
- * @link http://msdn.microsoft.com/en-US/library/ms189822%28v=sql.90%29.aspx
- */
- protected function getKeywords()
- {
- return array_merge(array_diff(parent::getKeywords(), ['DUMMY']), [
- 'EXTERNAL',
- 'PIVOT',
- 'REVERT',
- 'SECURITYAUDIT',
- 'TABLESAMPLE',
- 'UNPIVOT'
- ]);
- }
-}
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2008Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2008Keywords.php
deleted file mode 100644
index b5c38610afa..00000000000
--- a/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2008Keywords.php
+++ /dev/null
@@ -1,53 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Platforms\Keywords;
-
-use function array_merge;
-
-/**
- * Microsoft SQL Server 2008 reserved keyword dictionary.
- *
- * @license BSD http://www.opensource.org/licenses/bsd-license.php
- * @link www.doctrine-project.com
- * @since 2.3
- * @author Steve Müller
- */
-class SQLServer2008Keywords extends SQLServer2005Keywords
-{
- /**
- * {@inheritdoc}
- */
- public function getName()
- {
- return 'SQLServer2008';
- }
-
- /**
- * {@inheritdoc}
- *
- * @link http://msdn.microsoft.com/en-us/library/ms189822%28v=sql.100%29.aspx
- */
- protected function getKeywords()
- {
- return array_merge(parent::getKeywords(), [
- 'MERGE'
- ]);
- }
-}
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php
index bf621bff8af..34a6b517607 100644
--- a/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php
+++ b/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms\Keywords;
@@ -29,7 +12,7 @@
* @since 2.3
* @author Steve Müller
*/
-class SQLServer2012Keywords extends SQLServer2008Keywords
+class SQLServer2012Keywords extends SQLServerKeywords
{
/**
* {@inheritdoc}
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/SQLServerKeywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/SQLServerKeywords.php
index 5b65cbc8721..5c5d6a924b5 100644
--- a/lib/Doctrine/DBAL/Platforms/Keywords/SQLServerKeywords.php
+++ b/lib/Doctrine/DBAL/Platforms/Keywords/SQLServerKeywords.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms\Keywords;
@@ -143,6 +126,7 @@ protected function getKeywords()
'LIKE',
'LINENO',
'LOAD',
+ 'MERGE',
'NATIONAL',
'NOCHECK ',
'NONCLUSTERED',
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/SQLiteKeywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/SQLiteKeywords.php
index f240aa64469..5d34e0c9111 100644
--- a/lib/Doctrine/DBAL/Platforms/Keywords/SQLiteKeywords.php
+++ b/lib/Doctrine/DBAL/Platforms/Keywords/SQLiteKeywords.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms\Keywords;
diff --git a/lib/Doctrine/DBAL/Platforms/MySQL57Platform.php b/lib/Doctrine/DBAL/Platforms/MySQL57Platform.php
index 5b2328b2e65..e2c6fc3d937 100644
--- a/lib/Doctrine/DBAL/Platforms/MySQL57Platform.php
+++ b/lib/Doctrine/DBAL/Platforms/MySQL57Platform.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms;
diff --git a/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php b/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
index e318c2650ce..bfd3d914f48 100644
--- a/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+++ b/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms;
@@ -429,8 +412,8 @@ protected function _getCreateTableSQL($tableName, array $columns, array $options
$queryFields = $this->getColumnDeclarationListSQL($columns);
if (isset($options['uniqueConstraints']) && ! empty($options['uniqueConstraints'])) {
- foreach ($options['uniqueConstraints'] as $index => $definition) {
- $queryFields .= ', ' . $this->getUniqueConstraintDeclarationSQL($index, $definition);
+ foreach ($options['uniqueConstraints'] as $name => $definition) {
+ $queryFields .= ', ' . $this->getUniqueConstraintDeclarationSQL($name, $definition);
}
}
@@ -1030,36 +1013,36 @@ public function getReadLockSQL()
protected function initializeDoctrineTypeMappings()
{
$this->doctrineTypeMapping = [
- 'tinyint' => 'boolean',
- 'smallint' => 'smallint',
- 'mediumint' => 'integer',
- 'int' => 'integer',
- 'integer' => 'integer',
- 'bigint' => 'bigint',
- 'tinytext' => 'text',
- 'mediumtext' => 'text',
- 'longtext' => 'text',
- 'text' => 'text',
- 'varchar' => 'string',
- 'string' => 'string',
- 'char' => 'string',
- 'date' => 'date',
- 'datetime' => 'datetime',
- 'timestamp' => 'datetime',
- 'time' => 'time',
- 'float' => 'float',
- 'double' => 'float',
- 'real' => 'float',
- 'decimal' => 'decimal',
- 'numeric' => 'decimal',
- 'year' => 'date',
- 'longblob' => 'blob',
- 'blob' => 'blob',
- 'mediumblob' => 'blob',
- 'tinyblob' => 'blob',
- 'binary' => 'binary',
- 'varbinary' => 'binary',
- 'set' => 'simple_array',
+ 'bigint' => 'bigint',
+ 'binary' => 'binary',
+ 'blob' => 'blob',
+ 'char' => 'string',
+ 'date' => 'date',
+ 'datetime' => 'datetime',
+ 'decimal' => 'decimal',
+ 'double' => 'float',
+ 'float' => 'float',
+ 'int' => 'integer',
+ 'integer' => 'integer',
+ 'longblob' => 'blob',
+ 'longtext' => 'text',
+ 'mediumblob' => 'blob',
+ 'mediumint' => 'integer',
+ 'mediumtext' => 'text',
+ 'numeric' => 'decimal',
+ 'real' => 'float',
+ 'set' => 'simple_array',
+ 'smallint' => 'smallint',
+ 'string' => 'string',
+ 'text' => 'text',
+ 'time' => 'time',
+ 'timestamp' => 'datetime',
+ 'tinyblob' => 'blob',
+ 'tinyint' => 'boolean',
+ 'tinytext' => 'text',
+ 'varbinary' => 'binary',
+ 'varchar' => 'string',
+ 'year' => 'date',
];
}
diff --git a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php
index 1abc6cba108..6d965c32953 100644
--- a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+++ b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms;
@@ -396,11 +379,11 @@ public function getListSequencesSQL($database)
/**
* {@inheritDoc}
*/
- protected function _getCreateTableSQL($table, array $columns, array $options = [])
+ protected function _getCreateTableSQL($tableName, array $columns, array $options = [])
{
$indexes = $options['indexes'] ?? [];
$options['indexes'] = [];
- $sql = parent::_getCreateTableSQL($table, $columns, $options);
+ $sql = parent::_getCreateTableSQL($tableName, $columns, $options);
foreach ($columns as $name => $column) {
if (isset($column['sequence'])) {
@@ -409,13 +392,13 @@ protected function _getCreateTableSQL($table, array $columns, array $options = [
if (isset($column['autoincrement']) && $column['autoincrement'] ||
(isset($column['autoinc']) && $column['autoinc'])) {
- $sql = array_merge($sql, $this->getCreateAutoincrementSql($name, $table));
+ $sql = array_merge($sql, $this->getCreateAutoincrementSql($name, $tableName));
}
}
if (isset($indexes) && ! empty($indexes)) {
foreach ($indexes as $index) {
- $sql[] = $this->getCreateIndexSQL($index, $table);
+ $sql[] = $this->getCreateIndexSQL($index, $tableName);
}
}
@@ -1129,29 +1112,29 @@ public function getDummySelectSQL()
protected function initializeDoctrineTypeMappings()
{
$this->doctrineTypeMapping = [
- 'integer' => 'integer',
- 'number' => 'integer',
- 'pls_integer' => 'boolean',
- 'binary_integer' => 'boolean',
- 'varchar' => 'string',
- 'varchar2' => 'string',
- 'nvarchar2' => 'string',
- 'char' => 'string',
- 'nchar' => 'string',
- 'date' => 'date',
- 'timestamp' => 'datetime',
- 'timestamptz' => 'datetimetz',
- 'float' => 'float',
- 'binary_float' => 'float',
- 'binary_double' => 'float',
- 'long' => 'string',
- 'clob' => 'text',
- 'nclob' => 'text',
- 'raw' => 'binary',
- 'long raw' => 'blob',
- 'rowid' => 'string',
- 'urowid' => 'string',
- 'blob' => 'blob',
+ 'binary_double' => 'float',
+ 'binary_float' => 'float',
+ 'binary_integer' => 'boolean',
+ 'blob' => 'blob',
+ 'char' => 'string',
+ 'clob' => 'text',
+ 'date' => 'date',
+ 'float' => 'float',
+ 'integer' => 'integer',
+ 'long' => 'string',
+ 'long raw' => 'blob',
+ 'nchar' => 'string',
+ 'nclob' => 'text',
+ 'number' => 'integer',
+ 'nvarchar2' => 'string',
+ 'pls_integer' => 'boolean',
+ 'raw' => 'binary',
+ 'rowid' => 'string',
+ 'timestamp' => 'datetime',
+ 'timestamptz' => 'datetimetz',
+ 'urowid' => 'string',
+ 'varchar' => 'string',
+ 'varchar2' => 'string',
];
}
diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSQL91Platform.php b/lib/Doctrine/DBAL/Platforms/PostgreSQL91Platform.php
deleted file mode 100644
index 94d810483d4..00000000000
--- a/lib/Doctrine/DBAL/Platforms/PostgreSQL91Platform.php
+++ /dev/null
@@ -1,67 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Platforms;
-
-use function explode;
-
-/**
- * Provides the behavior, features and SQL dialect of the PostgreSQL 9.1 database platform.
- *
- * @author Martin Hasoň
- * @link www.doctrine-project.org
- * @since 2.5
- */
-class PostgreSQL91Platform extends PostgreSqlPlatform
-{
- /**
- * {@inheritDoc}
- */
- public function supportsColumnCollation()
- {
- return true;
- }
-
- /**
- * {@inheritdoc}
- */
- protected function getReservedKeywordsClass()
- {
- return Keywords\PostgreSQL91Keywords::class;
- }
-
- /**
- * {@inheritDoc}
- */
- public function getColumnCollationDeclarationSQL($collation)
- {
- return 'COLLATE ' . $this->quoteSingleIdentifier($collation);
- }
-
- /**
- * {@inheritDoc}
- */
- public function getListTableColumnsSQL($table, $database = null)
- {
- $sql = parent::getListTableColumnsSQL($table, $database);
- $parts = explode('AS complete_type,', $sql, 2);
-
- return $parts[0].'AS complete_type, (SELECT tc.collcollate FROM pg_catalog.pg_collation tc WHERE tc.oid = a.attcollation) AS collation,'.$parts[1];
- }
-}
diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php b/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php
deleted file mode 100644
index 052b75fa4af..00000000000
--- a/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php
+++ /dev/null
@@ -1,88 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Platforms;
-
-use Doctrine\DBAL\Types\Type;
-
-/**
- * Provides the behavior, features and SQL dialect of the PostgreSQL 9.2 database platform.
- *
- * @author Steve Müller
- * @link www.doctrine-project.org
- * @since 2.5
- */
-class PostgreSQL92Platform extends PostgreSQL91Platform
-{
- /**
- * {@inheritdoc}
- */
- public function getJsonTypeDeclarationSQL(array $field)
- {
- return 'JSON';
- }
-
- /**
- * {@inheritdoc}
- */
- public function getSmallIntTypeDeclarationSQL(array $field)
- {
- if ( ! empty($field['autoincrement'])) {
- return 'SMALLSERIAL';
- }
-
- return parent::getSmallIntTypeDeclarationSQL($field);
- }
-
- /**
- * {@inheritdoc}
- */
- public function hasNativeJsonType()
- {
- return true;
- }
-
- /**
- * {@inheritdoc}
- */
- protected function getReservedKeywordsClass()
- {
- return Keywords\PostgreSQL92Keywords::class;
- }
-
- /**
- * {@inheritdoc}
- */
- protected function initializeDoctrineTypeMappings()
- {
- parent::initializeDoctrineTypeMappings();
-
- $this->doctrineTypeMapping['json'] = Type::JSON;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getCloseActiveDatabaseConnectionsSQL($database)
- {
- $database = $this->quoteStringLiteral($database);
-
- return "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = $database";
- }
-}
diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSQL94Platform.php b/lib/Doctrine/DBAL/Platforms/PostgreSQL94Platform.php
index 68700b1962d..4cf1c1d31ce 100644
--- a/lib/Doctrine/DBAL/Platforms/PostgreSQL94Platform.php
+++ b/lib/Doctrine/DBAL/Platforms/PostgreSQL94Platform.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms;
@@ -28,7 +11,7 @@
* @link www.doctrine-project.org
* @since 2.6
*/
-class PostgreSQL94Platform extends PostgreSQL92Platform
+class PostgreSQL94Platform extends PostgreSqlPlatform
{
/**
* {@inheritdoc}
diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
index 61f6e09c497..fc38e67d49d 100644
--- a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+++ b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms;
@@ -48,7 +31,7 @@
use function trim;
/**
- * PostgreSqlPlatform.
+ * Provides the behavior, features and SQL dialect of the PostgreSQL 9.4+ database platform.
*
* @since 2.0
* @author Roman Borschel
@@ -405,6 +388,7 @@ public function getListTableColumnsSQL($table, $database = null)
quote_ident(a.attname) AS field,
t.typname AS type,
format_type(a.atttypid, a.atttypmod) AS complete_type,
+ (SELECT tc.collcollate FROM pg_catalog.pg_collation tc WHERE tc.oid = a.attcollation) AS collation,
(SELECT t1.typname FROM pg_catalog.pg_type t1 WHERE t1.oid = t.typbasetype) AS domain_type,
(SELECT format_type(t2.typbasetype, t2.typtypmod) FROM
pg_catalog.pg_type t2 WHERE t2.typtype = 'd' AND t2.oid = a.atttypid) AS domain_complete_type,
@@ -467,7 +451,7 @@ public function getCloseActiveDatabaseConnectionsSQL($database)
{
$database = $this->quoteStringLiteral($database);
- return "SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname = $database";
+ return 'SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = ' . $database;
}
/**
@@ -971,6 +955,10 @@ public function getBigIntTypeDeclarationSQL(array $field)
*/
public function getSmallIntTypeDeclarationSQL(array $field)
{
+ if (! empty($field['autoincrement'])) {
+ return 'SMALLSERIAL';
+ }
+
return 'SMALLINT';
}
@@ -1118,45 +1106,46 @@ public function getReadLockSQL()
protected function initializeDoctrineTypeMappings()
{
$this->doctrineTypeMapping = [
- 'smallint' => 'smallint',
- 'int2' => 'smallint',
- 'serial' => 'integer',
- 'serial4' => 'integer',
- 'int' => 'integer',
- 'int4' => 'integer',
- 'integer' => 'integer',
- 'bigserial' => 'bigint',
- 'serial8' => 'bigint',
- 'bigint' => 'bigint',
- 'int8' => 'bigint',
- 'bool' => 'boolean',
- 'boolean' => 'boolean',
- 'text' => 'text',
- 'tsvector' => 'text',
- 'varchar' => 'string',
- 'interval' => 'string',
- '_varchar' => 'string',
- 'char' => 'string',
- 'bpchar' => 'string',
- 'inet' => 'string',
- 'date' => 'date',
- 'datetime' => 'datetime',
- 'timestamp' => 'datetime',
- 'timestamptz' => 'datetimetz',
- 'time' => 'time',
- 'timetz' => 'time',
- 'float' => 'float',
- 'float4' => 'float',
- 'float8' => 'float',
- 'double' => 'float',
+ 'bigint' => 'bigint',
+ 'bigserial' => 'bigint',
+ 'bool' => 'boolean',
+ 'boolean' => 'boolean',
+ 'bpchar' => 'string',
+ 'bytea' => 'blob',
+ 'char' => 'string',
+ 'date' => 'date',
+ 'datetime' => 'datetime',
+ 'decimal' => 'decimal',
+ 'double' => 'float',
'double precision' => 'float',
- 'real' => 'float',
- 'decimal' => 'decimal',
- 'money' => 'decimal',
- 'numeric' => 'decimal',
- 'year' => 'date',
- 'uuid' => 'guid',
- 'bytea' => 'blob',
+ 'float' => 'float',
+ 'float4' => 'float',
+ 'float8' => 'float',
+ 'inet' => 'string',
+ 'int' => 'integer',
+ 'int2' => 'smallint',
+ 'int4' => 'integer',
+ 'int8' => 'bigint',
+ 'integer' => 'integer',
+ 'interval' => 'string',
+ 'json' => Type::JSON,
+ 'money' => 'decimal',
+ 'numeric' => 'decimal',
+ 'serial' => 'integer',
+ 'serial4' => 'integer',
+ 'serial8' => 'bigint',
+ 'real' => 'float',
+ 'smallint' => 'smallint',
+ 'text' => 'text',
+ 'time' => 'time',
+ 'timestamp' => 'datetime',
+ 'timestamptz' => 'datetimetz',
+ 'timetz' => 'time',
+ 'tsvector' => 'text',
+ 'uuid' => 'guid',
+ 'varchar' => 'string',
+ 'year' => 'date',
+ '_varchar' => 'string',
];
}
@@ -1184,6 +1173,14 @@ public function getBinaryDefaultLength()
return 0;
}
+ /**
+ * {@inheritdoc}
+ */
+ public function hasNativeJsonType()
+ {
+ return true;
+ }
+
/**
* {@inheritDoc}
*/
@@ -1222,6 +1219,30 @@ public function getDefaultValueDeclarationSQL($field)
return parent::getDefaultValueDeclarationSQL($field);
}
+ /**
+ * {@inheritdoc}
+ */
+ public function supportsColumnCollation()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getColumnCollationDeclarationSQL($collation)
+ {
+ return 'COLLATE ' . $this->quoteSingleIdentifier($collation);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getJsonTypeDeclarationSQL(array $field)
+ {
+ return 'JSON';
+ }
+
private function isSerialField(array $field) : bool
{
return $field['autoincrement'] ?? false === true && isset($field['type'])
diff --git a/lib/Doctrine/DBAL/Platforms/SQLAnywhere11Platform.php b/lib/Doctrine/DBAL/Platforms/SQLAnywhere11Platform.php
deleted file mode 100644
index e2773696072..00000000000
--- a/lib/Doctrine/DBAL/Platforms/SQLAnywhere11Platform.php
+++ /dev/null
@@ -1,47 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Platforms;
-
-/**
- * The SQLAnywhere11Platform provides the behavior, features and SQL dialect of the
- * SAP Sybase SQL Anywhere 11 database platform.
- *
- * @author Steve Müller
- * @link www.doctrine-project.org
- * @since 2.5
- */
-class SQLAnywhere11Platform extends SQLAnywherePlatform
-{
- /**
- * {@inheritdoc}
- */
- public function getRegexpExpression()
- {
- return 'REGEXP';
- }
-
- /**
- * {@inheritdoc}
- */
- protected function getReservedKeywordsClass()
- {
- return Keywords\SQLAnywhere11Keywords::class;
- }
-}
diff --git a/lib/Doctrine/DBAL/Platforms/SQLAnywhere12Platform.php b/lib/Doctrine/DBAL/Platforms/SQLAnywhere12Platform.php
deleted file mode 100644
index 1b52bfee56e..00000000000
--- a/lib/Doctrine/DBAL/Platforms/SQLAnywhere12Platform.php
+++ /dev/null
@@ -1,135 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Platforms;
-
-use Doctrine\DBAL\Schema\Index;
-use Doctrine\DBAL\Schema\Sequence;
-
-/**
- * The SQLAnywhere12Platform provides the behavior, features and SQL dialect of the
- * SAP Sybase SQL Anywhere 12 database platform.
- *
- * @author Steve Müller
- * @link www.doctrine-project.org
- * @since 2.5
- */
-class SQLAnywhere12Platform extends SQLAnywhere11Platform
-{
- /**
- * {@inheritdoc}
- */
- public function getCreateSequenceSQL(Sequence $sequence)
- {
- return 'CREATE SEQUENCE ' . $sequence->getQuotedName($this) .
- ' INCREMENT BY ' . $sequence->getAllocationSize() .
- ' START WITH ' . $sequence->getInitialValue() .
- ' MINVALUE ' . $sequence->getInitialValue();
- }
-
- /**
- * {@inheritdoc}
- */
- public function getAlterSequenceSQL(Sequence $sequence)
- {
- return 'ALTER SEQUENCE ' . $sequence->getQuotedName($this) .
- ' INCREMENT BY ' . $sequence->getAllocationSize();
- }
-
- /**
- * {@inheritdoc}
- */
- public function getDateTimeTzFormatString()
- {
- return 'Y-m-d H:i:s.uP';
- }
-
- /**
- * {@inheritdoc}
- */
- public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)
- {
- return 'TIMESTAMP WITH TIME ZONE';
- }
-
- /**
- * {@inheritdoc}
- */
- public function getDropSequenceSQL($sequence)
- {
- if ($sequence instanceof Sequence) {
- $sequence = $sequence->getQuotedName($this);
- }
-
- return 'DROP SEQUENCE ' . $sequence;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getListSequencesSQL($database)
- {
- return 'SELECT sequence_name, increment_by, start_with, min_value FROM SYS.SYSSEQUENCE';
- }
-
- /**
- * {@inheritdoc}
- */
- public function getSequenceNextValSQL($sequenceName)
- {
- return 'SELECT ' . $sequenceName . '.NEXTVAL';
- }
-
- /**
- * {@inheritdoc}
- */
- public function supportsSequences()
- {
- return true;
- }
-
- /**
- * {@inheritdoc}
- */
- protected function getAdvancedIndexOptionsSQL(Index $index)
- {
- if ( ! $index->isPrimary() && $index->isUnique() && $index->hasFlag('with_nulls_not_distinct')) {
- return ' WITH NULLS NOT DISTINCT' . parent::getAdvancedIndexOptionsSQL($index);
- }
-
- return parent::getAdvancedIndexOptionsSQL($index);
- }
-
- /**
- * {@inheritdoc}
- */
- protected function getReservedKeywordsClass()
- {
- return Keywords\SQLAnywhere12Keywords::class;
- }
-
- /**
- * {@inheritDoc}
- */
- protected function initializeDoctrineTypeMappings()
- {
- parent::initializeDoctrineTypeMappings();
- $this->doctrineTypeMapping['timestamp with time zone'] = 'datetime';
- }
-}
diff --git a/lib/Doctrine/DBAL/Platforms/SQLAnywhere16Platform.php b/lib/Doctrine/DBAL/Platforms/SQLAnywhere16Platform.php
deleted file mode 100644
index 161a4538b6c..00000000000
--- a/lib/Doctrine/DBAL/Platforms/SQLAnywhere16Platform.php
+++ /dev/null
@@ -1,60 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Platforms;
-
-use Doctrine\Common\Proxy\Exception\UnexpectedValueException;
-use Doctrine\DBAL\Schema\Index;
-
-/**
- * The SQLAnywhere16Platform provides the behavior, features and SQL dialect of the
- * SAP Sybase SQL Anywhere 16 database platform.
- *
- * @author Steve Müller
- * @link www.doctrine-project.org
- * @since 2.5
- */
-class SQLAnywhere16Platform extends SQLAnywhere12Platform
-{
- /**
- * {@inheritdoc}
- */
- protected function getAdvancedIndexOptionsSQL(Index $index)
- {
- if ($index->hasFlag('with_nulls_distinct') && $index->hasFlag('with_nulls_not_distinct')) {
- throw new UnexpectedValueException(
- 'An Index can either have a "with_nulls_distinct" or "with_nulls_not_distinct" flag but not both.'
- );
- }
-
- if ( ! $index->isPrimary() && $index->isUnique() && $index->hasFlag('with_nulls_distinct')) {
- return ' WITH NULLS DISTINCT' . parent::getAdvancedIndexOptionsSQL($index);
- }
-
- return parent::getAdvancedIndexOptionsSQL($index);
- }
-
- /**
- * {@inheritdoc}
- */
- protected function getReservedKeywordsClass()
- {
- return Keywords\SQLAnywhere16Keywords::class;
- }
-}
diff --git a/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php b/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php
index 98bc4689a9f..a7d7ccc200a 100644
--- a/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php
+++ b/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php
@@ -1,24 +1,8 @@
.
- */
namespace Doctrine\DBAL\Platforms;
+use Doctrine\Common\Proxy\Exception\UnexpectedValueException;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\LockMode;
use Doctrine\DBAL\Schema\Column;
@@ -27,6 +11,7 @@
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Identifier;
use Doctrine\DBAL\Schema\Index;
+use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\TransactionIsolationLevel;
@@ -47,7 +32,7 @@
/**
* The SQLAnywherePlatform provides the behavior, features and SQL dialect of the
- * SAP Sybase SQL Anywhere 10 database platform.
+ * SAP Sybase SQL Anywhere 12 database platform.
*
* @author Steve Müller
* @link www.doctrine-project.org
@@ -531,7 +516,7 @@ public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
*/
public function getDateTimeTzFormatString()
{
- return $this->getDateTimeFormatString();
+ return 'Y-m-d H:i:s.uP';
}
/**
@@ -991,6 +976,14 @@ public function getMd5Expression($column)
return "HASH(" . $column . ", 'MD5')";
}
+ /**
+ * {@inheritdoc}
+ */
+ public function getRegexpExpression()
+ {
+ return 'REGEXP';
+ }
+
/**
* {@inheritdoc}
*/
@@ -1157,22 +1150,65 @@ public function getTruncateTableSQL($tableName, $cascade = false)
/**
* {@inheritdoc}
*/
- public function getUniqueConstraintDeclarationSQL($name, Index $index)
+ public function getCreateSequenceSQL(Sequence $sequence)
{
- if ($index->isPrimary()) {
- throw new \InvalidArgumentException(
- 'Cannot create primary key constraint declarations with getUniqueConstraintDeclarationSQL().'
- );
- }
+ return 'CREATE SEQUENCE ' . $sequence->getQuotedName($this) .
+ ' INCREMENT BY ' . $sequence->getAllocationSize() .
+ ' START WITH ' . $sequence->getInitialValue() .
+ ' MINVALUE ' . $sequence->getInitialValue();
+ }
- if ( ! $index->isUnique()) {
- throw new \InvalidArgumentException(
- 'Can only create unique constraint declarations, no common index declarations with ' .
- 'getUniqueConstraintDeclarationSQL().'
- );
+ /**
+ * {@inheritdoc}
+ */
+ public function getAlterSequenceSQL(Sequence $sequence)
+ {
+ return 'ALTER SEQUENCE ' . $sequence->getQuotedName($this) .
+ ' INCREMENT BY ' . $sequence->getAllocationSize();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getDropSequenceSQL($sequence)
+ {
+ if ($sequence instanceof Sequence) {
+ $sequence = $sequence->getQuotedName($this);
}
- return $this->getTableConstraintDeclarationSQL($index, $name);
+ return 'DROP SEQUENCE ' . $sequence;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getListSequencesSQL($database)
+ {
+ return 'SELECT sequence_name, increment_by, start_with, min_value FROM SYS.SYSSEQUENCE';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getSequenceNextValSQL($sequenceName)
+ {
+ return 'SELECT ' . $sequenceName . '.NEXTVAL';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function supportsSequences()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)
+ {
+ return 'TIMESTAMP WITH TIME ZONE';
}
/**
@@ -1338,12 +1374,27 @@ protected function doModifyLimitQuery($query, $limit, $offset)
*/
protected function getAdvancedIndexOptionsSQL(Index $index)
{
+ if ($index->hasFlag('with_nulls_distinct') && $index->hasFlag('with_nulls_not_distinct')) {
+ throw new UnexpectedValueException(
+ 'An Index can either have a "with_nulls_distinct" or "with_nulls_not_distinct" flag but not both.'
+ );
+ }
+
$sql = '';
- if ( ! $index->isPrimary() && $index->hasFlag('for_olap_workload')) {
+ if (! $index->isPrimary() && $index->hasFlag('for_olap_workload')) {
$sql .= ' FOR OLAP WORKLOAD';
}
+
+ if (! $index->isPrimary() && $index->isUnique() && $index->hasFlag('with_nulls_not_distinct')) {
+ return ' WITH NULLS NOT DISTINCT' . $sql;
+ }
+
+ if (! $index->isPrimary() && $index->isUnique() && $index->hasFlag('with_nulls_distinct')) {
+ return ' WITH NULLS DISTINCT' . $sql;
+ }
+
return $sql;
}
@@ -1464,44 +1515,45 @@ protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed)
protected function initializeDoctrineTypeMappings()
{
$this->doctrineTypeMapping = [
- 'char' => 'string',
- 'long nvarchar' => 'text',
- 'long varchar' => 'text',
- 'nchar' => 'string',
- 'ntext' => 'text',
- 'nvarchar' => 'string',
- 'text' => 'text',
- 'uniqueidentifierstr' => 'guid',
- 'varchar' => 'string',
- 'xml' => 'text',
- 'bigint' => 'bigint',
- 'unsigned bigint' => 'bigint',
- 'bit' => 'boolean',
- 'decimal' => 'decimal',
- 'double' => 'float',
- 'float' => 'float',
- 'int' => 'integer',
- 'integer' => 'integer',
- 'unsigned int' => 'integer',
- 'numeric' => 'decimal',
- 'smallint' => 'smallint',
- 'unsigned smallint', 'smallint',
- 'tinyint' => 'smallint',
- 'unsigned tinyint', 'smallint',
- 'money' => 'decimal',
- 'smallmoney' => 'decimal',
- 'long varbit' => 'text',
- 'varbit' => 'string',
- 'date' => 'date',
- 'datetime' => 'datetime',
- 'smalldatetime' => 'datetime',
- 'time' => 'time',
- 'timestamp' => 'datetime',
- 'binary' => 'binary',
- 'image' => 'blob',
- 'long binary' => 'blob',
- 'uniqueidentifier' => 'guid',
- 'varbinary' => 'binary',
+ 'bigint' => 'bigint',
+ 'binary' => 'binary',
+ 'bit' => 'boolean',
+ 'char' => 'string',
+ 'decimal' => 'decimal',
+ 'date' => 'date',
+ 'datetime' => 'datetime',
+ 'double' => 'float',
+ 'float' => 'float',
+ 'image' => 'blob',
+ 'int' => 'integer',
+ 'integer' => 'integer',
+ 'long binary' => 'blob',
+ 'long nvarchar' => 'text',
+ 'long varbit' => 'text',
+ 'long varchar' => 'text',
+ 'money' => 'decimal',
+ 'nchar' => 'string',
+ 'ntext' => 'text',
+ 'numeric' => 'decimal',
+ 'nvarchar' => 'string',
+ 'smalldatetime' => 'datetime',
+ 'smallint' => 'smallint',
+ 'smallmoney' => 'decimal',
+ 'text' => 'text',
+ 'time' => 'time',
+ 'timestamp' => 'datetime',
+ 'timestamp with time zone' => 'datetime',
+ 'tinyint' => 'smallint',
+ 'uniqueidentifier' => 'guid',
+ 'uniqueidentifierstr' => 'guid',
+ 'unsigned bigint' => 'bigint',
+ 'unsigned int' => 'integer',
+ 'unsigned smallint' => 'smallint',
+ 'unsigned tinyint' => 'smallint',
+ 'varbinary' => 'binary',
+ 'varbit' => 'string',
+ 'varchar' => 'string',
+ 'xml' => 'text',
];
}
}
diff --git a/lib/Doctrine/DBAL/Platforms/SQLAzurePlatform.php b/lib/Doctrine/DBAL/Platforms/SQLAzurePlatform.php
index 71829cd0e0d..0e8a2188a90 100644
--- a/lib/Doctrine/DBAL/Platforms/SQLAzurePlatform.php
+++ b/lib/Doctrine/DBAL/Platforms/SQLAzurePlatform.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms;
@@ -28,7 +11,7 @@
*
* - Create tables with the FEDERATED ON syntax.
*/
-class SQLAzurePlatform extends SQLServer2008Platform
+class SQLAzurePlatform extends SQLServerPlatform
{
/**
* {@inheritDoc}
diff --git a/lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php b/lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php
deleted file mode 100644
index af42f516641..00000000000
--- a/lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php
+++ /dev/null
@@ -1,63 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Platforms;
-
-/**
- * Platform to ensure compatibility of Doctrine with Microsoft SQL Server 2005 version and
- * higher.
- *
- * Differences to SQL Server 2008 are:
- *
- * - DATETIME2 datatype does not exist, only DATETIME which has a precision of
- * 3. This is not supported by PHP DateTime, so we are emulating it by
- * setting .000 manually.
- * - Starting with SQLServer2005 VARCHAR(MAX), VARBINARY(MAX) and
- * NVARCHAR(max) replace the old TEXT, NTEXT and IMAGE types. See
- * {@link http://www.sql-server-helper.com/faq/sql-server-2005-varchar-max-p01.aspx}
- * for more information.
- */
-class SQLServer2005Platform extends SQLServerPlatform
-{
- /**
- * {@inheritDoc}
- */
- public function supportsLimitOffset()
- {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public function getClobTypeDeclarationSQL(array $field)
- {
- return 'VARCHAR(MAX)';
- }
-
- /**
- * {@inheritdoc}
- *
- * Returns Microsoft SQL Server 2005 specific keywords class
- */
- protected function getReservedKeywordsClass()
- {
- return Keywords\SQLServer2005Keywords::class;
- }
-}
diff --git a/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php b/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php
deleted file mode 100644
index b9a672e6c4b..00000000000
--- a/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php
+++ /dev/null
@@ -1,134 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Platforms;
-
-/**
- * Platform to ensure compatibility of Doctrine with Microsoft SQL Server 2008 version.
- *
- * Differences to SQL Server 2005 and before are that a new DATETIME2 type was
- * introduced that has a higher precision.
- */
-class SQLServer2008Platform extends SQLServer2005Platform
-{
- /**
- * {@inheritDoc}
- */
- public function getListTablesSQL()
- {
- // "sysdiagrams" table must be ignored as it's internal SQL Server table for Database Diagrams
- // Category 2 must be ignored as it is "MS SQL Server 'pseudo-system' object[s]" for replication
- return "SELECT name, SCHEMA_NAME (uid) AS schema_name FROM sysobjects WHERE type = 'U' AND name != 'sysdiagrams' AND category != 2 ORDER BY name";
- }
-
- /**
- * {@inheritDoc}
- */
- public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
- {
- // 3 - microseconds precision length
- // http://msdn.microsoft.com/en-us/library/ms187819.aspx
- return 'DATETIME2(6)';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getDateTypeDeclarationSQL(array $fieldDeclaration)
- {
- return 'DATE';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
- {
- return 'TIME(0)';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)
- {
- return 'DATETIMEOFFSET(6)';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getDateTimeFormatString()
- {
- return 'Y-m-d H:i:s.u';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getDateTimeTzFormatString()
- {
- return 'Y-m-d H:i:s.u P';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getDateFormatString()
- {
- return 'Y-m-d';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getTimeFormatString()
- {
- return 'H:i:s';
- }
-
- /**
- * {@inheritDoc}
- *
- * Adding Datetime2 Type
- */
- protected function initializeDoctrineTypeMappings()
- {
- parent::initializeDoctrineTypeMappings();
- $this->doctrineTypeMapping['datetime2'] = 'datetime';
- $this->doctrineTypeMapping['date'] = 'date';
- $this->doctrineTypeMapping['time'] = 'time';
- $this->doctrineTypeMapping['datetimeoffset'] = 'datetimetz';
- }
-
- /**
- * {@inheritdoc}
- *
- * Returns Microsoft SQL Server 2008 specific keywords class
- */
- protected function getReservedKeywordsClass()
- {
- return Keywords\SQLServer2008Keywords::class;
- }
-
- protected function getLikeWildcardCharacters() : string
- {
- return parent::getLikeWildcardCharacters() . '[]^';
- }
-}
diff --git a/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php b/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php
index df523ca764b..503c20c7613 100644
--- a/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php
+++ b/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms;
@@ -33,7 +16,7 @@
*
* @author Steve Müller
*/
-class SQLServer2012Platform extends SQLServer2008Platform
+class SQLServer2012Platform extends SQLServerPlatform
{
/**
* {@inheritdoc}
diff --git a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
index 3531afb9836..fefc9b6a612 100644
--- a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
+++ b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms;
@@ -399,18 +382,6 @@ public function getDefaultConstraintDeclarationSQL($table, array $column)
' FOR ' . $columnName->getQuotedName($this);
}
- /**
- * {@inheritDoc}
- */
- public function getUniqueConstraintDeclarationSQL($name, Index $index)
- {
- $constraint = parent::getUniqueConstraintDeclarationSQL($name, $index);
-
- $constraint = $this->_appendUniqueConstraintDefinition($constraint, $index);
-
- return $constraint;
- }
-
/**
* {@inheritDoc}
*/
@@ -896,7 +867,7 @@ public function getListTablesSQL()
{
// "sysdiagrams" table must be ignored as it's internal SQL Server table for Database Diagrams
// Category 2 must be ignored as it is "MS SQL Server 'pseudo-system' object[s]" for replication
- return "SELECT name FROM sysobjects WHERE type = 'U' AND name != 'sysdiagrams' AND category != 2 ORDER BY name";
+ return "SELECT name, SCHEMA_NAME (uid) AS schema_name FROM sysobjects WHERE type = 'U' AND name != 'sysdiagrams' AND category != 2 ORDER BY name";
}
/**
@@ -1182,6 +1153,14 @@ public function getGuidTypeDeclarationSQL(array $field)
return 'UNIQUEIDENTIFIER';
}
+ /**
+ * {@inheritDoc}
+ */
+ public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)
+ {
+ return 'DATETIMEOFFSET(6)';
+ }
+
/**
* {@inheritDoc}
*/
@@ -1227,7 +1206,9 @@ protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
*/
public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
{
- return 'DATETIME';
+ // 3 - microseconds precision length
+ // http://msdn.microsoft.com/en-us/library/ms187819.aspx
+ return 'DATETIME2(6)';
}
/**
@@ -1235,7 +1216,7 @@ public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
*/
public function getDateTypeDeclarationSQL(array $fieldDeclaration)
{
- return 'DATETIME';
+ return 'DATE';
}
/**
@@ -1243,7 +1224,7 @@ public function getDateTypeDeclarationSQL(array $fieldDeclaration)
*/
public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
{
- return 'DATETIME';
+ return 'TIME(0)';
}
/**
@@ -1385,7 +1366,7 @@ private function isOrderByInTopNSubquery($query, $currentPosition)
*/
public function supportsLimitOffset()
{
- return false;
+ return true;
}
/**
@@ -1427,7 +1408,7 @@ public function getTemporaryTableName($tableName)
*/
public function getDateTimeFormatString()
{
- return 'Y-m-d H:i:s.000';
+ return 'Y-m-d H:i:s.u';
}
/**
@@ -1435,7 +1416,7 @@ public function getDateTimeFormatString()
*/
public function getDateFormatString()
{
- return 'Y-m-d H:i:s.000';
+ return 'Y-m-d';
}
/**
@@ -1443,7 +1424,7 @@ public function getDateFormatString()
*/
public function getTimeFormatString()
{
- return 'Y-m-d H:i:s.000';
+ return 'H:i:s';
}
/**
@@ -1451,7 +1432,7 @@ public function getTimeFormatString()
*/
public function getDateTimeTzFormatString()
{
- return $this->getDateTimeFormatString();
+ return 'Y-m-d H:i:s.u P';
}
/**
@@ -1468,31 +1449,35 @@ public function getName()
protected function initializeDoctrineTypeMappings()
{
$this->doctrineTypeMapping = [
- 'bigint' => 'bigint',
- 'numeric' => 'decimal',
- 'bit' => 'boolean',
- 'smallint' => 'smallint',
- 'decimal' => 'decimal',
- 'smallmoney' => 'integer',
- 'int' => 'integer',
- 'tinyint' => 'smallint',
- 'money' => 'integer',
- 'float' => 'float',
- 'real' => 'float',
- 'double' => 'float',
+ 'bigint' => 'bigint',
+ 'binary' => 'binary',
+ 'bit' => 'boolean',
+ 'char' => 'string',
+ 'date' => 'date',
+ 'datetime' => 'datetime',
+ 'datetime2' => 'datetime',
+ 'datetimeoffset' => 'datetimetz',
+ 'decimal' => 'decimal',
+ 'double' => 'float',
'double precision' => 'float',
- 'smalldatetime' => 'datetime',
- 'datetime' => 'datetime',
- 'char' => 'string',
- 'varchar' => 'string',
- 'text' => 'text',
- 'nchar' => 'string',
- 'nvarchar' => 'string',
- 'ntext' => 'text',
- 'binary' => 'binary',
- 'varbinary' => 'binary',
- 'image' => 'blob',
+ 'float' => 'float',
+ 'image' => 'blob',
+ 'int' => 'integer',
+ 'money' => 'integer',
+ 'nchar' => 'string',
+ 'ntext' => 'text',
+ 'numeric' => 'decimal',
+ 'nvarchar' => 'string',
+ 'real' => 'float',
+ 'smalldatetime' => 'datetime',
+ 'smallint' => 'smallint',
+ 'smallmoney' => 'integer',
+ 'text' => 'text',
+ 'time' => 'time',
+ 'tinyint' => 'smallint',
'uniqueidentifier' => 'guid',
+ 'varbinary' => 'binary',
+ 'varchar' => 'string',
];
}
@@ -1653,6 +1638,14 @@ public function getColumnDeclarationSQL($name, array $field)
return $name . ' ' . $columnDef;
}
+ /**
+ * {@inheritdoc}
+ */
+ protected function getLikeWildcardCharacters() : string
+ {
+ return parent::getLikeWildcardCharacters() . '[]^';
+ }
+
/**
* Returns a unique default constraint name for a table and column.
*
diff --git a/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php b/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
index 251500d065d..1488621b941 100644
--- a/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
+++ b/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Platforms;
@@ -332,9 +315,9 @@ public function getForeignKeyDeclarationSQL(ForeignKeyConstraint $foreignKey)
/**
* {@inheritDoc}
*/
- protected function _getCreateTableSQL($name, array $columns, array $options = [])
+ protected function _getCreateTableSQL($tableName, array $columns, array $options = [])
{
- $name = str_replace('.', '__', $name);
+ $tableName = str_replace('.', '__', $tableName);
$queryFields = $this->getColumnDeclarationListSQL($columns);
if (isset($options['uniqueConstraints']) && ! empty($options['uniqueConstraints'])) {
@@ -354,7 +337,7 @@ protected function _getCreateTableSQL($name, array $columns, array $options = []
}
}
- $query[] = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')';
+ $query[] = 'CREATE TABLE ' . $tableName . ' (' . $queryFields . ')';
if (isset($options['alter']) && true === $options['alter']) {
return $query;
@@ -362,13 +345,13 @@ protected function _getCreateTableSQL($name, array $columns, array $options = []
if (isset($options['indexes']) && ! empty($options['indexes'])) {
foreach ($options['indexes'] as $indexDef) {
- $query[] = $this->getCreateIndexSQL($indexDef, $name);
+ $query[] = $this->getCreateIndexSQL($indexDef, $tableName);
}
}
if (isset($options['unique']) && ! empty($options['unique'])) {
foreach ($options['unique'] as $indexDef) {
- $query[] = $this->getCreateIndexSQL($indexDef, $name);
+ $query[] = $this->getCreateIndexSQL($indexDef, $tableName);
}
}
@@ -380,8 +363,10 @@ protected function _getCreateTableSQL($name, array $columns, array $options = []
*/
protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed)
{
- return $fixed ? ($length ? 'CHAR(' . $length . ')' : 'CHAR(255)')
- : ($length ? 'VARCHAR(' . $length . ')' : 'TEXT');
+ return $fixed
+ ? ($length ? 'CHAR(' . $length . ')' : 'CHAR(255)')
+ : ($length ? 'VARCHAR(' . $length . ')' : 'TEXT')
+ ;
}
/**
@@ -610,38 +595,38 @@ public function getInlineColumnCommentSQL($comment)
protected function initializeDoctrineTypeMappings()
{
$this->doctrineTypeMapping = [
- 'boolean' => 'boolean',
- 'tinyint' => 'boolean',
- 'smallint' => 'smallint',
- 'mediumint' => 'integer',
- 'int' => 'integer',
- 'integer' => 'integer',
- 'serial' => 'integer',
'bigint' => 'bigint',
'bigserial' => 'bigint',
- 'clob' => 'text',
- 'tinytext' => 'text',
- 'mediumtext' => 'text',
- 'longtext' => 'text',
- 'text' => 'text',
- 'varchar' => 'string',
- 'longvarchar' => 'string',
- 'varchar2' => 'string',
- 'nvarchar' => 'string',
- 'image' => 'string',
- 'ntext' => 'string',
+ 'blob' => 'blob',
+ 'boolean' => 'boolean',
'char' => 'string',
+ 'clob' => 'text',
'date' => 'date',
'datetime' => 'datetime',
- 'timestamp' => 'datetime',
- 'time' => 'time',
- 'float' => 'float',
+ 'decimal' => 'decimal',
'double' => 'float',
'double precision' => 'float',
- 'real' => 'float',
- 'decimal' => 'decimal',
+ 'float' => 'float',
+ 'image' => 'string',
+ 'int' => 'integer',
+ 'integer' => 'integer',
+ 'longtext' => 'text',
+ 'longvarchar' => 'string',
+ 'mediumint' => 'integer',
+ 'mediumtext' => 'text',
+ 'ntext' => 'string',
'numeric' => 'decimal',
- 'blob' => 'blob',
+ 'nvarchar' => 'string',
+ 'real' => 'float',
+ 'serial' => 'integer',
+ 'smallint' => 'smallint',
+ 'text' => 'text',
+ 'time' => 'time',
+ 'timestamp' => 'datetime',
+ 'tinyint' => 'boolean',
+ 'tinytext' => 'text',
+ 'varchar' => 'string',
+ 'varchar2' => 'string',
];
}
@@ -885,10 +870,11 @@ public function getAlterTableSQL(TableDiff $diff)
$sql = [];
$tableSql = [];
+
if ( ! $this->onSchemaAlterTable($diff, $tableSql)) {
$dataTable = new Table('__temp__'.$table->getName());
- $newTable = new Table($table->getQuotedName($this), $columns, $this->getPrimaryIndexInAlteredTable($diff), $this->getForeignKeysInAlteredTable($diff), 0, $table->getOptions());
+ $newTable = new Table($table->getQuotedName($this), $columns, $this->getPrimaryIndexInAlteredTable($diff), array(), $this->getForeignKeysInAlteredTable($diff), $table->getOptions());
$newTable->addOption('alter', true);
$sql = $this->getPreAlterTableIndexForeignKeySQL($diff);
diff --git a/lib/Doctrine/DBAL/Portability/Connection.php b/lib/Doctrine/DBAL/Portability/Connection.php
index 723a333bb18..d5921d85871 100644
--- a/lib/Doctrine/DBAL/Portability/Connection.php
+++ b/lib/Doctrine/DBAL/Portability/Connection.php
@@ -1,29 +1,14 @@
.
- */
namespace Doctrine\DBAL\Portability;
use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\DBAL\ColumnCase;
+use Doctrine\DBAL\Driver\PDOConnection;
+use Doctrine\DBAL\Driver\ResultStatement;
+use Doctrine\DBAL\Driver\Statement as DriverStatement;
use const CASE_LOWER;
use const CASE_UPPER;
-use function func_get_args;
/**
* Portability wrapper for a Connection.
@@ -45,7 +30,6 @@ class Connection extends \Doctrine\DBAL\Connection
const PORTABILITY_POSTGRESQL = 13;
const PORTABILITY_SQLITE = 13;
const PORTABILITY_OTHERVENDORS = 12;
- const PORTABILITY_DRIZZLE = 13;
const PORTABILITY_SQLANYWHERE = 13;
const PORTABILITY_SQLSRV = 13;
@@ -74,8 +58,6 @@ public function connect()
$params['portability'] = $params['portability'] & self::PORTABILITY_POSTGRESQL;
} elseif ($this->getDatabasePlatform()->getName() === "sqlite") {
$params['portability'] = $params['portability'] & self::PORTABILITY_SQLITE;
- } elseif ($this->getDatabasePlatform()->getName() === "drizzle") {
- $params['portability'] = $params['portability'] & self::PORTABILITY_DRIZZLE;
} elseif ($this->getDatabasePlatform()->getName() === 'sqlanywhere') {
$params['portability'] = $params['portability'] & self::PORTABILITY_SQLANYWHERE;
} elseif ($this->getDatabasePlatform()->getName() === 'db2') {
@@ -89,9 +71,9 @@ public function connect()
}
if (isset($params['fetch_case']) && $this->portability & self::PORTABILITY_FIX_CASE) {
- if ($this->_conn instanceof \Doctrine\DBAL\Driver\PDOConnection) {
+ if ($this->_conn instanceof PDOConnection) {
// make use of c-level support for case handling
- $this->_conn->setAttribute(\PDO::ATTR_CASE, $params['fetch_case']);
+ $this->_conn->getWrappedConnection()->setAttribute(\PDO::ATTR_CASE, $params['fetch_case']);
} else {
$this->case = ($params['fetch_case'] === ColumnCase::LOWER) ? CASE_LOWER : CASE_UPPER;
}
@@ -120,7 +102,7 @@ public function getFetchCase()
/**
* {@inheritdoc}
*/
- public function executeQuery($query, array $params = [], $types = [], QueryCacheProfile $qcp = null)
+ public function executeQuery(string $query, array $params = [], $types = [], ?QueryCacheProfile $qcp = null) : ResultStatement
{
$stmt = new Statement(parent::executeQuery($query, $params, $types, $qcp), $this);
$stmt->setFetchMode($this->defaultFetchMode);
@@ -131,9 +113,9 @@ public function executeQuery($query, array $params = [], $types = [], QueryCache
/**
* {@inheritdoc}
*/
- public function prepare($statement)
+ public function prepare(string $sql) : DriverStatement
{
- $stmt = new Statement(parent::prepare($statement), $this);
+ $stmt = new Statement(parent::prepare($sql), $this);
$stmt->setFetchMode($this->defaultFetchMode);
return $stmt;
@@ -142,11 +124,11 @@ public function prepare($statement)
/**
* {@inheritdoc}
*/
- public function query()
+ public function query(string $sql) : ResultStatement
{
$this->connect();
- $stmt = $this->_conn->query(...func_get_args());
+ $stmt = $this->_conn->query($sql);
$stmt = new Statement($stmt, $this);
$stmt->setFetchMode($this->defaultFetchMode);
diff --git a/lib/Doctrine/DBAL/Portability/Statement.php b/lib/Doctrine/DBAL/Portability/Statement.php
index bd9a445fe59..5a908b8db84 100644
--- a/lib/Doctrine/DBAL/Portability/Statement.php
+++ b/lib/Doctrine/DBAL/Portability/Statement.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Portability;
@@ -127,11 +110,11 @@ public function execute($params = null)
/**
* {@inheritdoc}
*/
- public function setFetchMode($fetchMode, $arg1 = null, $arg2 = null)
+ public function setFetchMode($fetchMode, ...$args)
{
$this->defaultFetchMode = $fetchMode;
- return $this->stmt->setFetchMode($fetchMode, $arg1, $arg2);
+ return $this->stmt->setFetchMode($fetchMode, ...$args);
}
/**
@@ -147,11 +130,11 @@ public function getIterator()
/**
* {@inheritdoc}
*/
- public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
+ public function fetch($fetchMode = null, ...$args)
{
$fetchMode = $fetchMode ?: $this->defaultFetchMode;
- $row = $this->stmt->fetch($fetchMode);
+ $row = $this->stmt->fetch($fetchMode, ...$args);
$iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM);
$fixCase = ! is_null($this->case)
@@ -166,15 +149,11 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
/**
* {@inheritdoc}
*/
- public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
+ public function fetchAll($fetchMode = null, ...$args)
{
$fetchMode = $fetchMode ?: $this->defaultFetchMode;
- if ($fetchArgument) {
- $rows = $this->stmt->fetchAll($fetchMode, $fetchArgument);
- } else {
- $rows = $this->stmt->fetchAll($fetchMode);
- }
+ $rows = $this->stmt->fetchAll($fetchMode, ...$args);
$iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM);
$fixCase = ! is_null($this->case)
@@ -255,7 +234,7 @@ public function fetchColumn($columnIndex = 0)
/**
* {@inheritdoc}
*/
- public function rowCount()
+ public function rowCount() : int
{
return $this->stmt->rowCount();
}
diff --git a/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php b/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php
index 00802a44ee8..23db991cecd 100644
--- a/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php
+++ b/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Query\Expression;
diff --git a/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php b/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php
index 1ee72484775..b9e8559f000 100644
--- a/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php
+++ b/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Query\Expression;
diff --git a/lib/Doctrine/DBAL/Query/QueryBuilder.php b/lib/Doctrine/DBAL/Query/QueryBuilder.php
index 0eac78a56aa..df45bed472f 100644
--- a/lib/Doctrine/DBAL/Query/QueryBuilder.php
+++ b/lib/Doctrine/DBAL/Query/QueryBuilder.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Query;
@@ -1149,7 +1132,7 @@ private function getFromClauses()
// Loop through all FROM clauses
foreach ($this->sqlParts['from'] as $from) {
- if ($from['alias'] === null) {
+ if ($from['alias'] === null || $from['alias'] === $from['table']) {
$tableSql = $from['table'];
$tableReference = $from['table'];
} else {
@@ -1208,7 +1191,14 @@ private function getSQLForInsert()
*/
private function getSQLForUpdate()
{
- $table = $this->sqlParts['from']['table'] . ($this->sqlParts['from']['alias'] ? ' ' . $this->sqlParts['from']['alias'] : '');
+ $from = $this->sqlParts['from'];
+
+ if ($from['alias'] === null || $from['alias'] === $from['table']) {
+ $table = $from['table'];
+ } else {
+ $table = $from['table'] . ' ' . $from['alias'];
+ }
+
$query = 'UPDATE ' . $table
. ' SET ' . implode(", ", $this->sqlParts['set'])
. ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : '');
@@ -1223,7 +1213,14 @@ private function getSQLForUpdate()
*/
private function getSQLForDelete()
{
- $table = $this->sqlParts['from']['table'] . ($this->sqlParts['from']['alias'] ? ' ' . $this->sqlParts['from']['alias'] : '');
+ $from = $this->sqlParts['from'];
+
+ if ($from['alias'] === null || $from['alias'] === $from['table']) {
+ $table = $from['table'];
+ } else {
+ $table = $from['table'] . ' ' . $from['alias'];
+ }
+
$query = 'DELETE FROM ' . $table . ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : '');
return $query;
diff --git a/lib/Doctrine/DBAL/Query/QueryException.php b/lib/Doctrine/DBAL/Query/QueryException.php
index 45a3d55f650..ef12dca1a62 100644
--- a/lib/Doctrine/DBAL/Query/QueryException.php
+++ b/lib/Doctrine/DBAL/Query/QueryException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Query;
diff --git a/lib/Doctrine/DBAL/SQLParserUtils.php b/lib/Doctrine/DBAL/SQLParserUtils.php
index e635af754d9..924988cc02f 100644
--- a/lib/Doctrine/DBAL/SQLParserUtils.php
+++ b/lib/Doctrine/DBAL/SQLParserUtils.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL;
@@ -100,7 +83,7 @@ public static function getPlaceholderPositions($statement, $isPositional = true)
*
* @throws SQLParserUtilsException
*/
- public static function expandListParameters($query, $params, $types)
+ public static function expandListParameters(string $query, array $params = [], array $types = []) : array
{
$isPositional = is_int(key($params));
$arrayPositions = [];
diff --git a/lib/Doctrine/DBAL/SQLParserUtilsException.php b/lib/Doctrine/DBAL/SQLParserUtilsException.php
index e7c15c53e84..4d17d226757 100644
--- a/lib/Doctrine/DBAL/SQLParserUtilsException.php
+++ b/lib/Doctrine/DBAL/SQLParserUtilsException.php
@@ -1,23 +1,4 @@
.
- */
namespace Doctrine\DBAL;
diff --git a/lib/Doctrine/DBAL/Schema/AbstractAsset.php b/lib/Doctrine/DBAL/Schema/AbstractAsset.php
index 3ac7fb8bd37..78d2e99f41e 100644
--- a/lib/Doctrine/DBAL/Schema/AbstractAsset.php
+++ b/lib/Doctrine/DBAL/Schema/AbstractAsset.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
index c8677901116..708df09ac99 100644
--- a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
+++ b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
@@ -291,12 +274,14 @@ public function listTableDetails($tableName)
{
$columns = $this->listTableColumns($tableName);
$foreignKeys = [];
+
if ($this->_platform->supportsForeignKeyConstraints()) {
$foreignKeys = $this->listTableForeignKeys($tableName);
}
+
$indexes = $this->listTableIndexes($tableName);
- return new Table($tableName, $columns, $indexes, $foreignKeys, false, []);
+ return new Table($tableName, $columns, $indexes, [], $foreignKeys, []);
}
/**
@@ -632,6 +617,7 @@ public function dropAndCreateView(View $view)
public function alterTable(TableDiff $tableDiff)
{
$queries = $this->_platform->getAlterTableSQL($tableDiff);
+
if (is_array($queries) && count($queries)) {
foreach ($queries as $ddlQuery) {
$this->_execSql($ddlQuery);
diff --git a/lib/Doctrine/DBAL/Schema/Column.php b/lib/Doctrine/DBAL/Schema/Column.php
index eead5e6aa82..862240c6e7d 100644
--- a/lib/Doctrine/DBAL/Schema/Column.php
+++ b/lib/Doctrine/DBAL/Schema/Column.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/ColumnDiff.php b/lib/Doctrine/DBAL/Schema/ColumnDiff.php
index 65517d75cb5..196f83e3634 100644
--- a/lib/Doctrine/DBAL/Schema/ColumnDiff.php
+++ b/lib/Doctrine/DBAL/Schema/ColumnDiff.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/Comparator.php b/lib/Doctrine/DBAL/Schema/Comparator.php
index 6e0c42fe4ae..d5e1560d6b4 100644
--- a/lib/Doctrine/DBAL/Schema/Comparator.php
+++ b/lib/Doctrine/DBAL/Schema/Comparator.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/Constraint.php b/lib/Doctrine/DBAL/Schema/Constraint.php
index 2e68a771019..8ca3b14c16b 100644
--- a/lib/Doctrine/DBAL/Schema/Constraint.php
+++ b/lib/Doctrine/DBAL/Schema/Constraint.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php b/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php
index c97685b5d0e..aa1f1207bb1 100644
--- a/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php
+++ b/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php b/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php
deleted file mode 100644
index a10eb3da066..00000000000
--- a/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php
+++ /dev/null
@@ -1,122 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL\Schema;
-
-use Doctrine\DBAL\Types\Type;
-use function explode;
-use function strtolower;
-use function trim;
-
-/**
- * Schema manager for the Drizzle RDBMS.
- *
- * @author Kim Hemsø Rasmussen
- */
-class DrizzleSchemaManager extends AbstractSchemaManager
-{
- /**
- * {@inheritdoc}
- */
- protected function _getPortableTableColumnDefinition($tableColumn)
- {
- $dbType = strtolower($tableColumn['DATA_TYPE']);
-
- $type = $this->_platform->getDoctrineTypeMapping($dbType);
- $type = $this->extractDoctrineTypeFromComment($tableColumn['COLUMN_COMMENT'], $type);
- $tableColumn['COLUMN_COMMENT'] = $this->removeDoctrineTypeFromComment($tableColumn['COLUMN_COMMENT'], $type);
-
- $options = [
- 'notnull' => !(bool) $tableColumn['IS_NULLABLE'],
- 'length' => (int) $tableColumn['CHARACTER_MAXIMUM_LENGTH'],
- 'default' => $tableColumn['COLUMN_DEFAULT'] ?? null,
- 'autoincrement' => (bool) $tableColumn['IS_AUTO_INCREMENT'],
- 'scale' => (int) $tableColumn['NUMERIC_SCALE'],
- 'precision' => (int) $tableColumn['NUMERIC_PRECISION'],
- 'comment' => isset($tableColumn['COLUMN_COMMENT']) && '' !== $tableColumn['COLUMN_COMMENT']
- ? $tableColumn['COLUMN_COMMENT']
- : null,
- ];
-
- $column = new Column($tableColumn['COLUMN_NAME'], Type::getType($type), $options);
-
- if ( ! empty($tableColumn['COLLATION_NAME'])) {
- $column->setPlatformOption('collation', $tableColumn['COLLATION_NAME']);
- }
-
- return $column;
- }
-
- /**
- * {@inheritdoc}
- */
- protected function _getPortableDatabaseDefinition($database)
- {
- return $database['SCHEMA_NAME'];
- }
-
- /**
- * {@inheritdoc}
- */
- protected function _getPortableTableDefinition($table)
- {
- return $table['TABLE_NAME'];
- }
-
- /**
- * {@inheritdoc}
- */
- public function _getPortableTableForeignKeyDefinition($tableForeignKey)
- {
- $columns = [];
- foreach (explode(',', $tableForeignKey['CONSTRAINT_COLUMNS']) as $value) {
- $columns[] = trim($value, ' `');
- }
-
- $refColumns = [];
- foreach (explode(',', $tableForeignKey['REFERENCED_TABLE_COLUMNS']) as $value) {
- $refColumns[] = trim($value, ' `');
- }
-
- return new ForeignKeyConstraint(
- $columns,
- $tableForeignKey['REFERENCED_TABLE_NAME'],
- $refColumns,
- $tableForeignKey['CONSTRAINT_NAME'],
- [
- 'onUpdate' => $tableForeignKey['UPDATE_RULE'],
- 'onDelete' => $tableForeignKey['DELETE_RULE'],
- ]
- );
- }
-
- /**
- * {@inheritdoc}
- */
- protected function _getPortableTableIndexesList($tableIndexes, $tableName = null)
- {
- $indexes = [];
- foreach ($tableIndexes as $k) {
- $k['primary'] = (boolean) $k['primary'];
- $indexes[] = $k;
- }
-
- return parent::_getPortableTableIndexesList($indexes, $tableName);
- }
-}
diff --git a/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php b/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php
index a50b7a0b5c5..962fcb8a0f1 100644
--- a/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php
+++ b/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/Identifier.php b/lib/Doctrine/DBAL/Schema/Identifier.php
index babe583e43a..79686448c0b 100644
--- a/lib/Doctrine/DBAL/Schema/Identifier.php
+++ b/lib/Doctrine/DBAL/Schema/Identifier.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/Index.php b/lib/Doctrine/DBAL/Schema/Index.php
index 78a2322c8d0..ed2bbfbb027 100644
--- a/lib/Doctrine/DBAL/Schema/Index.php
+++ b/lib/Doctrine/DBAL/Schema/Index.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
@@ -77,13 +60,15 @@ public function __construct($indexName, array $columns, $isUnique = false, $isPr
$isUnique = $isUnique || $isPrimary;
$this->_setName($indexName);
- $this->_isUnique = $isUnique;
+
+ $this->_isUnique = $isUnique;
$this->_isPrimary = $isPrimary;
- $this->options = $options;
+ $this->options = $options;
foreach ($columns as $column) {
$this->_addColumn($column);
}
+
foreach ($flags as $flag) {
$this->addFlag($flag);
}
diff --git a/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
index a56a6af86b2..1989872372a 100644
--- a/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
+++ b/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php
index dafc1fac20c..f00e2b54b18 100644
--- a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php
+++ b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
index 6eeaf119193..879094620b6 100644
--- a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
+++ b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php b/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php
index 4025c0345c8..2a42a9a966d 100644
--- a/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php
+++ b/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php b/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php
index 13525b7b2af..4e45cd4472d 100644
--- a/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php
+++ b/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/Schema.php b/lib/Doctrine/DBAL/Schema/Schema.php
index 88e5ed0ded7..49606d67a05 100644
--- a/lib/Doctrine/DBAL/Schema/Schema.php
+++ b/lib/Doctrine/DBAL/Schema/Schema.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/SchemaConfig.php b/lib/Doctrine/DBAL/Schema/SchemaConfig.php
index c8c7673bae2..e0b09050e1d 100644
--- a/lib/Doctrine/DBAL/Schema/SchemaConfig.php
+++ b/lib/Doctrine/DBAL/Schema/SchemaConfig.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/SchemaDiff.php b/lib/Doctrine/DBAL/Schema/SchemaDiff.php
index ec9ccba933d..12ef74dabe4 100644
--- a/lib/Doctrine/DBAL/Schema/SchemaDiff.php
+++ b/lib/Doctrine/DBAL/Schema/SchemaDiff.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/SchemaException.php b/lib/Doctrine/DBAL/Schema/SchemaException.php
index 7285d81cbf0..1832999c9b5 100644
--- a/lib/Doctrine/DBAL/Schema/SchemaException.php
+++ b/lib/Doctrine/DBAL/Schema/SchemaException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
@@ -34,7 +17,8 @@ class SchemaException extends \Doctrine\DBAL\DBALException
const SEQUENCE_ALREADY_EXISTS = 80;
const INDEX_INVALID_NAME = 90;
const FOREIGNKEY_DOESNT_EXIST = 100;
- const NAMESPACE_ALREADY_EXISTS = 110;
+ const CONSTRAINT_DOESNT_EXIST = 110;
+ const NAMESPACE_ALREADY_EXISTS = 120;
/**
* @param string $tableName
@@ -145,6 +129,17 @@ public static function sequenceDoesNotExist($sequenceName)
return new self("There exists no sequence with the name '".$sequenceName."'.", self::SEQUENCE_DOENST_EXIST);
}
+ /**
+ * @param string $constraintName
+ * @param string $table
+ *
+ * @return \Doctrine\DBAL\Schema\SchemaException
+ */
+ static public function uniqueConstraintDoesNotExist($constraintName, $table)
+ {
+ return new self("There exists no unique constraint with the name '$constraintName' on table '$table'.", self::CONSTRAINT_DOESNT_EXIST);
+ }
+
/**
* @param string $fkName
* @param string $table
diff --git a/lib/Doctrine/DBAL/Schema/Sequence.php b/lib/Doctrine/DBAL/Schema/Sequence.php
index 7d255305e02..9c735725525 100644
--- a/lib/Doctrine/DBAL/Schema/Sequence.php
+++ b/lib/Doctrine/DBAL/Schema/Sequence.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
index ee11049aa36..bce4d7e8dad 100644
--- a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
+++ b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/Synchronizer/AbstractSchemaSynchronizer.php b/lib/Doctrine/DBAL/Schema/Synchronizer/AbstractSchemaSynchronizer.php
index 3158df47de1..1515304dc32 100644
--- a/lib/Doctrine/DBAL/Schema/Synchronizer/AbstractSchemaSynchronizer.php
+++ b/lib/Doctrine/DBAL/Schema/Synchronizer/AbstractSchemaSynchronizer.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema\Synchronizer;
diff --git a/lib/Doctrine/DBAL/Schema/Synchronizer/SchemaSynchronizer.php b/lib/Doctrine/DBAL/Schema/Synchronizer/SchemaSynchronizer.php
index b65efbbb99f..d2913ab42c9 100644
--- a/lib/Doctrine/DBAL/Schema/Synchronizer/SchemaSynchronizer.php
+++ b/lib/Doctrine/DBAL/Schema/Synchronizer/SchemaSynchronizer.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema\Synchronizer;
diff --git a/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php b/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php
index f22607e6b96..9e25c36ed9d 100644
--- a/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php
+++ b/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema\Synchronizer;
diff --git a/lib/Doctrine/DBAL/Schema/Table.php b/lib/Doctrine/DBAL/Schema/Table.php
index 40af2b2198f..de740e7dfb6 100644
--- a/lib/Doctrine/DBAL/Schema/Table.php
+++ b/lib/Doctrine/DBAL/Schema/Table.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
@@ -66,6 +49,11 @@ class Table extends AbstractAsset
*/
protected $_primaryKeyName = false;
+ /**
+ * @var UniqueConstraint[]
+ */
+ protected $_uniqueConstraints = [];
+
/**
* @var ForeignKeyConstraint[]
*/
@@ -85,13 +73,20 @@ class Table extends AbstractAsset
* @param string $tableName
* @param Column[] $columns
* @param Index[] $indexes
+ * @param UniqueConstraint[] $uniqueConstraints
* @param ForeignKeyConstraint[] $fkConstraints
- * @param int $idGeneratorType
* @param array $options
*
* @throws DBALException
*/
- public function __construct($tableName, array $columns=[], array $indexes=[], array $fkConstraints=[], $idGeneratorType = 0, array $options=[])
+ public function __construct(
+ $tableName,
+ array $columns = [],
+ array $indexes = [],
+ array $uniqueConstraints = [],
+ array $fkConstraints = [],
+ array $options = []
+ )
{
if (strlen($tableName) == 0) {
throw DBALException::invalidTableName($tableName);
@@ -107,8 +102,12 @@ public function __construct($tableName, array $columns=[], array $indexes=[], ar
$this->_addIndex($idx);
}
- foreach ($fkConstraints as $constraint) {
- $this->_addForeignKeyConstraint($constraint);
+ foreach ($uniqueConstraints as $uniqueConstraint) {
+ $this->_addUniqueConstraint($uniqueConstraint);
+ }
+
+ foreach ($fkConstraints as $fkConstraint) {
+ $this->_addForeignKeyConstraint($fkConstraint);
}
$this->_options = $options;
@@ -124,18 +123,6 @@ public function setSchemaConfig(SchemaConfig $schemaConfig)
$this->_schemaConfig = $schemaConfig;
}
- /**
- * @return int
- */
- protected function _getMaxIdentifierLength()
- {
- if ($this->_schemaConfig instanceof SchemaConfig) {
- return $this->_schemaConfig->getMaxIdentifierLength();
- }
-
- return 63;
- }
-
/**
* Sets the Primary Key.
*
@@ -156,6 +143,25 @@ public function setPrimaryKey(array $columns, $indexName = false)
return $this;
}
+ /**
+ * @param array $columnNames
+ * @param string|null $indexName
+ * @param array $flags
+ * @param array $options
+ *
+ * @return self
+ */
+ public function addUniqueConstraint(array $columnNames, $indexName = null, array $flags = array(), array $options = [])
+ {
+ if ($indexName == null) {
+ $indexName = $this->_generateIdentifierName(
+ array_merge(array($this->getName()), $columnNames), "uniq", $this->_getMaxIdentifierLength()
+ );
+ }
+
+ return $this->_addUniqueConstraint($this->_createUniqueConstraint($columnNames, $indexName, $flags, $options));
+ }
+
/**
* @param array $columnNames
* @param string|null $indexName
@@ -198,9 +204,11 @@ public function dropPrimaryKey()
public function dropIndex($indexName)
{
$indexName = $this->normalizeIdentifier($indexName);
+
if ( ! $this->hasIndex($indexName)) {
throw SchemaException::indexDoesNotExist($indexName, $this->_name);
}
+
unset($this->_indexes[$indexName]);
}
@@ -287,37 +295,6 @@ public function columnsAreIndexed(array $columnsNames)
return false;
}
- /**
- * @param array $columnNames
- * @param string $indexName
- * @param bool $isUnique
- * @param bool $isPrimary
- * @param array $flags
- * @param array $options
- *
- * @return Index
- *
- * @throws SchemaException
- */
- private function _createIndex(array $columnNames, $indexName, $isUnique, $isPrimary, array $flags = [], array $options = [])
- {
- if (preg_match('(([^a-zA-Z0-9_]+))', $this->normalizeIdentifier($indexName))) {
- throw SchemaException::indexNameInvalid($indexName);
- }
-
- foreach ($columnNames as $columnName => $indexColOptions) {
- if (is_numeric($columnName) && is_string($indexColOptions)) {
- $columnName = $indexColOptions;
- }
-
- if ( ! $this->hasColumn($columnName)) {
- throw SchemaException::columnDoesNotExist($columnName, $this->_name);
- }
- }
-
- return new Index($indexName, $columnNames, $isUnique, $isPrimary, $flags, $options);
- }
-
/**
* @param string $columnName
* @param string $typeName
@@ -346,9 +323,11 @@ public function addColumn($columnName, $typeName, array $options=[])
*/
public function renameColumn($oldColumnName, $newColumnName)
{
- throw new DBALException("Table#renameColumn() was removed, because it drops and recreates " .
- "the column instead. There is no fix available, because a schema diff cannot reliably detect if a " .
- "column was renamed or one column was created and another one dropped.");
+ throw new DBALException(
+ "Table#renameColumn() was removed, because it drops and recreates the column instead. " .
+ "There is no fix available, because a schema diff cannot reliably detect if a column " .
+ "was renamed or one column was created and another one dropped."
+ );
}
/**
@@ -362,6 +341,7 @@ public function renameColumn($oldColumnName, $newColumnName)
public function changeColumn($columnName, array $options)
{
$column = $this->getColumn($columnName);
+
$column->setOptions($options);
return $this;
@@ -377,6 +357,7 @@ public function changeColumn($columnName, array $options)
public function dropColumn($columnName)
{
$columnName = $this->normalizeIdentifier($columnName);
+
unset($this->_columns[$columnName]);
return $this;
@@ -397,7 +378,11 @@ public function dropColumn($columnName)
*/
public function addForeignKeyConstraint($foreignTable, array $localColumnNames, array $foreignColumnNames, array $options=[], $constraintName = null)
{
- $constraintName = $constraintName ?: $this->_generateIdentifierName(array_merge((array) $this->getName(), $localColumnNames), "fk", $this->_getMaxIdentifierLength());
+ if ( ! $constraintName) {
+ $constraintName = $this->_generateIdentifierName(
+ array_merge((array) $this->getName(), $localColumnNames), "fk", $this->_getMaxIdentifierLength()
+ );
+ }
return $this->addNamedForeignKeyConstraint($constraintName, $foreignTable, $localColumnNames, $foreignColumnNames, $options);
}
@@ -455,9 +440,8 @@ public function addNamedForeignKeyConstraint($name, $foreignTable, array $localC
$constraint = new ForeignKeyConstraint(
$localColumnNames, $foreignTable, $foreignColumnNames, $name, $options
);
- $this->_addForeignKeyConstraint($constraint);
- return $this;
+ return $this->_addForeignKeyConstraint($constraint);
}
/**
@@ -474,139 +458,95 @@ public function addOption($name, $value)
}
/**
- * @param Column $column
+ * Returns whether this table has a foreign key constraint with the given name.
*
- * @return void
+ * @param string $constraintName
*
- * @throws SchemaException
+ * @return bool
*/
- protected function _addColumn(Column $column)
+ public function hasForeignKey($constraintName)
{
- $columnName = $column->getName();
- $columnName = $this->normalizeIdentifier($columnName);
-
- if (isset($this->_columns[$columnName])) {
- throw SchemaException::columnAlreadyExists($this->getName(), $columnName);
- }
+ $constraintName = $this->normalizeIdentifier($constraintName);
- $this->_columns[$columnName] = $column;
+ return isset($this->_fkConstraints[$constraintName]);
}
/**
- * Adds an index to the table.
+ * Returns the foreign key constraint with the given name.
*
- * @param Index $indexCandidate
+ * @param string $constraintName The constraint name.
*
- * @return self
+ * @return ForeignKeyConstraint
*
- * @throws SchemaException
+ * @throws SchemaException If the foreign key does not exist.
*/
- protected function _addIndex(Index $indexCandidate)
+ public function getForeignKey($constraintName)
{
- $indexName = $indexCandidate->getName();
- $indexName = $this->normalizeIdentifier($indexName);
- $replacedImplicitIndexes = [];
-
- foreach ($this->implicitIndexes as $name => $implicitIndex) {
- if ($implicitIndex->isFullfilledBy($indexCandidate) && isset($this->_indexes[$name])) {
- $replacedImplicitIndexes[] = $name;
- }
- }
-
- if ((isset($this->_indexes[$indexName]) && ! in_array($indexName, $replacedImplicitIndexes, true)) ||
- ($this->_primaryKeyName != false && $indexCandidate->isPrimary())
- ) {
- throw SchemaException::indexAlreadyExists($indexName, $this->_name);
- }
-
- foreach ($replacedImplicitIndexes as $name) {
- unset($this->_indexes[$name], $this->implicitIndexes[$name]);
- }
+ $constraintName = $this->normalizeIdentifier($constraintName);
- if ($indexCandidate->isPrimary()) {
- $this->_primaryKeyName = $indexName;
+ if ( ! $this->hasForeignKey($constraintName)) {
+ throw SchemaException::foreignKeyDoesNotExist($constraintName, $this->_name);
}
- $this->_indexes[$indexName] = $indexCandidate;
-
- return $this;
+ return $this->_fkConstraints[$constraintName];
}
/**
- * @param ForeignKeyConstraint $constraint
+ * Removes the foreign key constraint with the given name.
+ *
+ * @param string $constraintName The constraint name.
*
* @return void
+ *
+ * @throws SchemaException
*/
- protected function _addForeignKeyConstraint(ForeignKeyConstraint $constraint)
+ public function removeForeignKey($constraintName)
{
- $constraint->setLocalTable($this);
-
- if (strlen($constraint->getName())) {
- $name = $constraint->getName();
- } else {
- $name = $this->_generateIdentifierName(
- array_merge((array) $this->getName(), $constraint->getLocalColumns()), "fk", $this->_getMaxIdentifierLength()
- );
- }
- $name = $this->normalizeIdentifier($name);
-
- $this->_fkConstraints[$name] = $constraint;
-
- // add an explicit index on the foreign key columns. If there is already an index that fulfils this requirements drop the request.
- // In the case of __construct calling this method during hydration from schema-details all the explicitly added indexes
- // lead to duplicates. This creates computation overhead in this case, however no duplicate indexes are ever added (based on columns).
- $indexName = $this->_generateIdentifierName(
- array_merge([$this->getName()], $constraint->getColumns()),
- "idx",
- $this->_getMaxIdentifierLength()
- );
- $indexCandidate = $this->_createIndex($constraint->getColumns(), $indexName, false, false);
+ $constraintName = $this->normalizeIdentifier($constraintName);
- foreach ($this->_indexes as $existingIndex) {
- if ($indexCandidate->isFullfilledBy($existingIndex)) {
- return;
- }
+ if ( ! $this->hasForeignKey($constraintName)) {
+ throw SchemaException::foreignKeyDoesNotExist($constraintName, $this->_name);
}
- $this->_addIndex($indexCandidate);
- $this->implicitIndexes[$this->normalizeIdentifier($indexName)] = $indexCandidate;
+ unset($this->_fkConstraints[$constraintName]);
}
/**
- * Returns whether this table has a foreign key constraint with the given name.
+ * Returns whether this table has a unique constraint with the given name.
*
* @param string $constraintName
*
- * @return bool
+ * @return boolean
*/
- public function hasForeignKey($constraintName)
+ public function hasUniqueConstraint($constraintName)
{
$constraintName = $this->normalizeIdentifier($constraintName);
- return isset($this->_fkConstraints[$constraintName]);
+ return isset($this->_uniqueConstraints[$constraintName]);
}
/**
- * Returns the foreign key constraint with the given name.
+ * Returns the unique constraint with the given name.
*
* @param string $constraintName The constraint name.
*
- * @return ForeignKeyConstraint
+ * @return UniqueConstraint
*
* @throws SchemaException If the foreign key does not exist.
*/
- public function getForeignKey($constraintName)
+ public function getUniqueConstraint($constraintName)
{
$constraintName = $this->normalizeIdentifier($constraintName);
- if (!$this->hasForeignKey($constraintName)) {
- throw SchemaException::foreignKeyDoesNotExist($constraintName, $this->_name);
+
+ if ( ! $this->hasUniqueConstraint($constraintName)) {
+ throw SchemaException::uniqueConstraintDoesNotExist($constraintName, $this->_name);
}
- return $this->_fkConstraints[$constraintName];
+ return $this->_uniqueConstraints[$constraintName];
}
/**
- * Removes the foreign key constraint with the given name.
+ * Removes the unique constraint with the given name.
*
* @param string $constraintName The constraint name.
*
@@ -614,14 +554,15 @@ public function getForeignKey($constraintName)
*
* @throws SchemaException
*/
- public function removeForeignKey($constraintName)
+ public function removeUniqueConstraint($constraintName)
{
$constraintName = $this->normalizeIdentifier($constraintName);
- if (!$this->hasForeignKey($constraintName)) {
- throw SchemaException::foreignKeyDoesNotExist($constraintName, $this->_name);
+
+ if ( ! $this->hasUniqueConstraint($constraintName)) {
+ throw SchemaException::uniqueConstraintDoesNotExist($constraintName, $this->_name);
}
- unset($this->_fkConstraints[$constraintName]);
+ unset($this->_uniqueConstraints[$constraintName]);
}
/**
@@ -630,12 +571,26 @@ public function removeForeignKey($constraintName)
*/
public function getColumns()
{
- $primaryKeyColumns = [];
+ $columns = $this->_columns;
+ $pkCols = [];
+ $fkCols = [];
+
if ($this->hasPrimaryKey()) {
- $primaryKeyColumns = $this->filterColumns($this->getPrimaryKey()->getColumns());
+ $pkCols = $this->getPrimaryKey()->getColumns();
+ }
+
+ foreach ($this->getForeignKeys() as $fk) {
+ /* @var $fk ForeignKeyConstraint */
+ $fkCols = array_merge($fkCols, $fk->getColumns());
}
- return array_merge($primaryKeyColumns, $this->getForeignKeyColumns(), $this->_columns);
+ $colNames = array_unique(array_merge($pkCols, $fkCols, array_keys($columns)));
+
+ uksort($columns, function ($a, $b) use ($colNames) {
+ return (array_search($a, $colNames) >= array_search($b, $colNames));
+ });
+
+ return $columns;
}
/**
@@ -645,10 +600,12 @@ public function getColumns()
private function getForeignKeyColumns()
{
$foreignKeyColumns = [];
+
foreach ($this->getForeignKeys() as $foreignKey) {
/* @var $foreignKey ForeignKeyConstraint */
$foreignKeyColumns = array_merge($foreignKeyColumns, $foreignKey->getColumns());
}
+
return $this->filterColumns($foreignKeyColumns);
}
@@ -690,6 +647,7 @@ public function hasColumn($columnName)
public function getColumn($columnName)
{
$columnName = $this->normalizeIdentifier($columnName);
+
if ( ! $this->hasColumn($columnName)) {
throw SchemaException::columnDoesNotExist($columnName, $this->_name);
}
@@ -704,11 +662,10 @@ public function getColumn($columnName)
*/
public function getPrimaryKey()
{
- if ( ! $this->hasPrimaryKey()) {
- return null;
- }
-
- return $this->getIndex($this->_primaryKeyName);
+ return $this->hasPrimaryKey()
+ ? $this->getIndex($this->_primaryKeyName)
+ : null
+ ;
}
/**
@@ -762,6 +719,7 @@ public function hasIndex($indexName)
public function getIndex($indexName)
{
$indexName = $this->normalizeIdentifier($indexName);
+
if ( ! $this->hasIndex($indexName)) {
throw SchemaException::indexDoesNotExist($indexName, $this->_name);
}
@@ -777,6 +735,16 @@ public function getIndexes()
return $this->_indexes;
}
+ /**
+ * Returns the unique constraints.
+ *
+ * @return UniqueConstraint[]
+ */
+ public function getUniqueConstraints()
+ {
+ return $this->_uniqueConstraints;
+ }
+
/**
* Returns the foreign key constraints.
*
@@ -847,15 +815,167 @@ public function __clone()
foreach ($this->_columns as $k => $column) {
$this->_columns[$k] = clone $column;
}
+
foreach ($this->_indexes as $k => $index) {
$this->_indexes[$k] = clone $index;
}
+
foreach ($this->_fkConstraints as $k => $fk) {
$this->_fkConstraints[$k] = clone $fk;
$this->_fkConstraints[$k]->setLocalTable($this);
}
}
+ /**
+ * @return integer
+ */
+ protected function _getMaxIdentifierLength()
+ {
+ return ($this->_schemaConfig instanceof SchemaConfig)
+ ? $this->_schemaConfig->getMaxIdentifierLength()
+ : 63
+ ;
+ }
+
+ /**
+ * @param Column $column
+ *
+ * @return void
+ *
+ * @throws SchemaException
+ */
+ protected function _addColumn(Column $column)
+ {
+ $columnName = $column->getName();
+ $columnName = $this->normalizeIdentifier($columnName);
+
+ if (isset($this->_columns[$columnName])) {
+ throw SchemaException::columnAlreadyExists($this->getName(), $columnName);
+ }
+
+ $this->_columns[$columnName] = $column;
+ }
+
+ /**
+ * Adds an index to the table.
+ *
+ * @param Index $indexCandidate
+ *
+ * @return self
+ *
+ * @throws SchemaException
+ */
+ protected function _addIndex(Index $indexCandidate)
+ {
+ $indexName = $indexCandidate->getName();
+ $indexName = $this->normalizeIdentifier($indexName);
+ $replacedImplicitIndexes = [];
+
+ foreach ($this->implicitIndexes as $name => $implicitIndex) {
+ if ($implicitIndex->isFullfilledBy($indexCandidate) && isset($this->_indexes[$name])) {
+ $replacedImplicitIndexes[] = $name;
+ }
+ }
+
+ if ((isset($this->_indexes[$indexName]) && ! in_array($indexName, $replacedImplicitIndexes, true)) ||
+ ($this->_primaryKeyName != false && $indexCandidate->isPrimary())
+ ) {
+ throw SchemaException::indexAlreadyExists($indexName, $this->_name);
+ }
+
+ foreach ($replacedImplicitIndexes as $name) {
+ unset($this->_indexes[$name], $this->implicitIndexes[$name]);
+ }
+
+ if ($indexCandidate->isPrimary()) {
+ $this->_primaryKeyName = $indexName;
+ }
+
+ $this->_indexes[$indexName] = $indexCandidate;
+
+ return $this;
+ }
+
+ /**
+ * @param UniqueConstraint $constraint
+ *
+ * @return self
+ */
+ protected function _addUniqueConstraint(UniqueConstraint $constraint)
+ {
+ $name = strlen($constraint->getName())
+ ? $constraint->getName()
+ : $this->_generateIdentifierName(
+ array_merge((array) $this->getName(), $constraint->getLocalColumns()), "fk", $this->_getMaxIdentifierLength()
+ )
+ ;
+
+ $name = $this->normalizeIdentifier($name);
+
+ $this->_uniqueConstraints[$name] = $constraint;
+
+ // If there is already an index that fulfills this requirements drop the request. In the case of __construct
+ // calling this method during hydration from schema-details all the explicitly added indexes lead to duplicates.
+ // This creates computation overhead in this case, however no duplicate indexes are ever added (column based).
+ $indexName = $this->_generateIdentifierName(
+ array_merge(array($this->getName()), $constraint->getColumns()), "idx", $this->_getMaxIdentifierLength()
+ );
+
+ $indexCandidate = $this->_createIndex($constraint->getColumns(), $indexName, true, false);
+
+ foreach ($this->_indexes as $existingIndex) {
+ if ($indexCandidate->isFullfilledBy($existingIndex)) {
+ return $this;
+ }
+ }
+
+ $this->implicitIndexes[$this->normalizeIdentifier($indexName)] = $indexCandidate;
+
+ return $this;
+ }
+
+ /**
+ * @param ForeignKeyConstraint $constraint
+ *
+ * @return self
+ */
+ protected function _addForeignKeyConstraint(ForeignKeyConstraint $constraint)
+ {
+ $constraint->setLocalTable($this);
+
+ $name = strlen($constraint->getName())
+ ? $constraint->getName()
+ : $this->_generateIdentifierName(
+ array_merge((array) $this->getName(), $constraint->getLocalColumns()), "fk", $this->_getMaxIdentifierLength()
+ )
+ ;
+
+ $name = $this->normalizeIdentifier($name);
+
+ $this->_fkConstraints[$name] = $constraint;
+
+ // add an explicit index on the foreign key columns.
+ // If there is already an index that fulfills this requirements drop the request. In the case of __construct
+ // calling this method during hydration from schema-details all the explicitly added indexes lead to duplicates.
+ // This creates computation overhead in this case, however no duplicate indexes are ever added (column based).
+ $indexName = $this->_generateIdentifierName(
+ array_merge(array($this->getName()), $constraint->getColumns()), "idx", $this->_getMaxIdentifierLength()
+ );
+
+ $indexCandidate = $this->_createIndex($constraint->getColumns(), $indexName, false, false);
+
+ foreach ($this->_indexes as $existingIndex) {
+ if ($indexCandidate->isFullfilledBy($existingIndex)) {
+ return $this;
+ }
+ }
+
+ $this->_addIndex($indexCandidate);
+ $this->implicitIndexes[$this->normalizeIdentifier($indexName)] = $indexCandidate;
+
+ return $this;
+ }
+
/**
* Normalizes a given identifier.
*
@@ -869,4 +989,64 @@ private function normalizeIdentifier($identifier)
{
return $this->trimQuotes(strtolower($identifier));
}
+
+ /**
+ * @param array $columnNames
+ * @param string $indexName
+ * @param array $flags
+ * @param array $options
+ *
+ * @return UniqueConstraint
+ *
+ * @throws SchemaException
+ */
+ private function _createUniqueConstraint(array $columnNames, $indexName, array $flags = array(), array $options = [])
+ {
+ if (preg_match('(([^a-zA-Z0-9_]+))', $this->normalizeIdentifier($indexName))) {
+ throw SchemaException::indexNameInvalid($indexName);
+ }
+
+ foreach ($columnNames as $columnName => $indexColOptions) {
+ if (is_numeric($columnName) && is_string($indexColOptions)) {
+ $columnName = $indexColOptions;
+ }
+
+ if ( ! $this->hasColumn($columnName)) {
+ throw SchemaException::columnDoesNotExist($columnName, $this->_name);
+ }
+ }
+
+ return new UniqueConstraint($indexName, $columnNames, $flags, $options);
+ }
+
+ /**
+ * @param array $columnNames
+ * @param string $indexName
+ * @param boolean $isUnique
+ * @param boolean $isPrimary
+ * @param array $flags
+ * @param array $options
+ *
+ * @return Index
+ *
+ * @throws SchemaException
+ */
+ private function _createIndex(array $columnNames, $indexName, $isUnique, $isPrimary, array $flags = [], array $options = [])
+ {
+ if (preg_match('(([^a-zA-Z0-9_]+))', $this->normalizeIdentifier($indexName))) {
+ throw SchemaException::indexNameInvalid($indexName);
+ }
+
+ foreach ($columnNames as $columnName => $indexColOptions) {
+ if (is_numeric($columnName) && is_string($indexColOptions)) {
+ $columnName = $indexColOptions;
+ }
+
+ if ( ! $this->hasColumn($columnName)) {
+ throw SchemaException::columnDoesNotExist($columnName, $this->_name);
+ }
+ }
+
+ return new Index($indexName, $columnNames, $isUnique, $isPrimary, $flags, $options);
+ }
}
diff --git a/lib/Doctrine/DBAL/Schema/TableDiff.php b/lib/Doctrine/DBAL/Schema/TableDiff.php
index 50d2a6c3077..0cc66bb1858 100644
--- a/lib/Doctrine/DBAL/Schema/TableDiff.php
+++ b/lib/Doctrine/DBAL/Schema/TableDiff.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/UniqueConstraint.php b/lib/Doctrine/DBAL/Schema/UniqueConstraint.php
new file mode 100644
index 00000000000..d5b94fd3126
--- /dev/null
+++ b/lib/Doctrine/DBAL/Schema/UniqueConstraint.php
@@ -0,0 +1,183 @@
+
+ * @link www.doctrine-project.org
+ * @since 3.0
+ */
+class UniqueConstraint extends AbstractAsset implements Constraint
+{
+ /**
+ * Asset identifier instances of the column names the unique constraint is associated with.
+ * array($columnName => Identifier)
+ *
+ * @var Identifier[]
+ */
+ protected $columns = array();
+
+ /**
+ * Platform specific flags
+ * array($flagName => true)
+ *
+ * @var array
+ */
+ protected $flags = array();
+
+ /**
+ * Platform specific options
+ *
+ * @var array
+ */
+ private $options = array();
+
+ /**
+ * @param string $indexName
+ * @param string[] $columns
+ * @param array $flags
+ * @param array $options
+ */
+ public function __construct($indexName, array $columns, array $flags = array(), array $options = array())
+ {
+ $this->_setName($indexName);
+
+ $this->options = $options;
+
+ foreach ($columns as $column) {
+ $this->_addColumn($column);
+ }
+
+ foreach ($flags as $flag) {
+ $this->addFlag($flag);
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getColumns()
+ {
+ return array_keys($this->columns);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getQuotedColumns(AbstractPlatform $platform)
+ {
+ $columns = array();
+
+ foreach ($this->columns as $column) {
+ $columns[] = $column->getQuotedName($platform);
+ }
+
+ return $columns;
+ }
+
+ /**
+ * @return string[]
+ */
+ public function getUnquotedColumns()
+ {
+ return array_map(array($this, 'trimQuotes'), $this->getColumns());
+ }
+
+ /**
+ * Returns platform specific flags for unique constraint.
+ *
+ * @return string[]
+ */
+ public function getFlags()
+ {
+ return array_keys($this->flags);
+ }
+
+ /**
+ * Adds flag for a unique constraint that translates to platform specific handling.
+ *
+ * @example $uniqueConstraint->addFlag('CLUSTERED')
+ *
+ * @param string $flag
+ *
+ * @return self
+ */
+ public function addFlag($flag)
+ {
+ $this->flags[strtolower($flag)] = true;
+
+ return $this;
+ }
+
+ /**
+ * Does this unique constraint have a specific flag?
+ *
+ * @param string $flag
+ *
+ * @return boolean
+ */
+ public function hasFlag($flag)
+ {
+ return isset($this->flags[strtolower($flag)]);
+ }
+
+ /**
+ * Removes a flag.
+ *
+ * @param string $flag
+ *
+ * @return void
+ */
+ public function removeFlag($flag)
+ {
+ unset($this->flags[strtolower($flag)]);
+ }
+
+ /**
+ * @param string $name
+ *
+ * @return boolean
+ */
+ public function hasOption($name)
+ {
+ return isset($this->options[strtolower($name)]);
+ }
+
+ /**
+ * @param string $name
+ *
+ * @return mixed
+ */
+ public function getOption($name)
+ {
+ return $this->options[strtolower($name)];
+ }
+
+ /**
+ * @return array
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * @param string $column
+ *
+ * @return void
+ *
+ * @throws \InvalidArgumentException
+ */
+ protected function _addColumn($column)
+ {
+ if (is_string($column)) {
+ $this->columns[$column] = new Identifier($column);
+ } else {
+ throw new \InvalidArgumentException("Expecting a string as Index Column");
+ }
+ }
+}
diff --git a/lib/Doctrine/DBAL/Schema/View.php b/lib/Doctrine/DBAL/Schema/View.php
index 0ef7d305bbb..9d54cd1ff68 100644
--- a/lib/Doctrine/DBAL/Schema/View.php
+++ b/lib/Doctrine/DBAL/Schema/View.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema;
diff --git a/lib/Doctrine/DBAL/Schema/Visitor/AbstractVisitor.php b/lib/Doctrine/DBAL/Schema/Visitor/AbstractVisitor.php
index 7bf5b2fec32..ec5a41ddebc 100644
--- a/lib/Doctrine/DBAL/Schema/Visitor/AbstractVisitor.php
+++ b/lib/Doctrine/DBAL/Schema/Visitor/AbstractVisitor.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema\Visitor;
diff --git a/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php b/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php
index 0d92edb0998..70328e6d45b 100644
--- a/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php
+++ b/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema\Visitor;
diff --git a/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php b/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php
index abd183d5ae5..b5f0e0ce934 100644
--- a/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php
+++ b/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema\Visitor;
diff --git a/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php b/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php
index daec58ef064..56908226350 100644
--- a/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php
+++ b/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema\Visitor;
diff --git a/lib/Doctrine/DBAL/Schema/Visitor/NamespaceVisitor.php b/lib/Doctrine/DBAL/Schema/Visitor/NamespaceVisitor.php
index da7b1edbcaa..b04935982c3 100644
--- a/lib/Doctrine/DBAL/Schema/Visitor/NamespaceVisitor.php
+++ b/lib/Doctrine/DBAL/Schema/Visitor/NamespaceVisitor.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema\Visitor;
diff --git a/lib/Doctrine/DBAL/Schema/Visitor/RemoveNamespacedAssets.php b/lib/Doctrine/DBAL/Schema/Visitor/RemoveNamespacedAssets.php
index e328d071cde..5f3c8645c07 100644
--- a/lib/Doctrine/DBAL/Schema/Visitor/RemoveNamespacedAssets.php
+++ b/lib/Doctrine/DBAL/Schema/Visitor/RemoveNamespacedAssets.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema\Visitor;
diff --git a/lib/Doctrine/DBAL/Schema/Visitor/SchemaDiffVisitor.php b/lib/Doctrine/DBAL/Schema/Visitor/SchemaDiffVisitor.php
index bde4453b357..69bb23ecf59 100644
--- a/lib/Doctrine/DBAL/Schema/Visitor/SchemaDiffVisitor.php
+++ b/lib/Doctrine/DBAL/Schema/Visitor/SchemaDiffVisitor.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema\Visitor;
diff --git a/lib/Doctrine/DBAL/Schema/Visitor/Visitor.php b/lib/Doctrine/DBAL/Schema/Visitor/Visitor.php
index 656f0e20c6f..e3dbed7839a 100644
--- a/lib/Doctrine/DBAL/Schema/Visitor/Visitor.php
+++ b/lib/Doctrine/DBAL/Schema/Visitor/Visitor.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Schema\Visitor;
diff --git a/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php b/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php
index 8145480d819..771aad8715a 100644
--- a/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php
+++ b/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Sharding;
diff --git a/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php b/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php
index 7f9a33fc5b2..dc606a8e616 100644
--- a/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php
+++ b/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Sharding;
diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php
index 2b700b38a4a..6272d476075 100644
--- a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php
+++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Sharding\SQLAzure;
diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php
index 255ca8b418e..0882a2d78bd 100644
--- a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php
+++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Sharding\SQLAzure;
diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php
index 92851d00182..a53eee738b2 100644
--- a/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php
+++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Sharding\SQLAzure\Schema;
diff --git a/lib/Doctrine/DBAL/Sharding/ShardChoser/MultiTenantShardChoser.php b/lib/Doctrine/DBAL/Sharding/ShardChoser/MultiTenantShardChoser.php
index f1d51b8c957..9340ace68d9 100644
--- a/lib/Doctrine/DBAL/Sharding/ShardChoser/MultiTenantShardChoser.php
+++ b/lib/Doctrine/DBAL/Sharding/ShardChoser/MultiTenantShardChoser.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Sharding\ShardChoser;
diff --git a/lib/Doctrine/DBAL/Sharding/ShardChoser/ShardChoser.php b/lib/Doctrine/DBAL/Sharding/ShardChoser/ShardChoser.php
index f0233722769..08eacdde1b2 100644
--- a/lib/Doctrine/DBAL/Sharding/ShardChoser/ShardChoser.php
+++ b/lib/Doctrine/DBAL/Sharding/ShardChoser/ShardChoser.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Sharding\ShardChoser;
diff --git a/lib/Doctrine/DBAL/Sharding/ShardManager.php b/lib/Doctrine/DBAL/Sharding/ShardManager.php
index 98c8351d7c2..76b743edfa7 100644
--- a/lib/Doctrine/DBAL/Sharding/ShardManager.php
+++ b/lib/Doctrine/DBAL/Sharding/ShardManager.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Sharding;
diff --git a/lib/Doctrine/DBAL/Sharding/ShardingException.php b/lib/Doctrine/DBAL/Sharding/ShardingException.php
index aa14d32af30..9951a60090a 100644
--- a/lib/Doctrine/DBAL/Sharding/ShardingException.php
+++ b/lib/Doctrine/DBAL/Sharding/ShardingException.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Sharding;
diff --git a/lib/Doctrine/DBAL/Statement.php b/lib/Doctrine/DBAL/Statement.php
index 9774e4afe0a..550faafd286 100644
--- a/lib/Doctrine/DBAL/Statement.php
+++ b/lib/Doctrine/DBAL/Statement.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL;
@@ -161,16 +144,12 @@ public function execute($params = null)
}
$logger = $this->conn->getConfiguration()->getSQLLogger();
- if ($logger) {
- $logger->startQuery($this->sql, $this->params, $this->types);
- }
+ $logger->startQuery($this->sql, $this->params, $this->types);
try {
$stmt = $this->stmt->execute($params);
} catch (\Exception $ex) {
- if ($logger) {
- $logger->stopQuery();
- }
+ $logger->stopQuery();
throw DBALException::driverExceptionDuringQuery(
$this->conn->getDriver(),
$ex,
@@ -179,9 +158,7 @@ public function execute($params = null)
);
}
- if ($logger) {
- $logger->stopQuery();
- }
+ $logger->stopQuery();
$this->params = [];
$this->types = [];
@@ -231,15 +208,9 @@ public function errorInfo()
/**
* {@inheritdoc}
*/
- public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
+ public function setFetchMode($fetchMode, ...$args)
{
- if ($arg2 === null) {
- return $this->stmt->setFetchMode($fetchMode);
- } elseif ($arg3 === null) {
- return $this->stmt->setFetchMode($fetchMode, $arg2);
- }
-
- return $this->stmt->setFetchMode($fetchMode, $arg2, $arg3);
+ return $this->stmt->setFetchMode($fetchMode, ...$args);
}
/**
@@ -255,21 +226,17 @@ public function getIterator()
/**
* {@inheritdoc}
*/
- public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
+ public function fetch($fetchMode = null, ...$args)
{
- return $this->stmt->fetch($fetchMode);
+ return $this->stmt->fetch($fetchMode, ...$args);
}
/**
* {@inheritdoc}
*/
- public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
+ public function fetchAll($fetchMode = null, ...$args)
{
- if ($fetchArgument) {
- return $this->stmt->fetchAll($fetchMode, $fetchArgument);
- }
-
- return $this->stmt->fetchAll($fetchMode);
+ return $this->stmt->fetchAll($fetchMode, ...$args);
}
/**
@@ -289,7 +256,7 @@ public function fetchColumn($columnIndex = 0)
*
* @return int The number of affected rows.
*/
- public function rowCount()
+ public function rowCount() : int
{
return $this->stmt->rowCount();
}
diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php
index 78921f39c2e..63daa2ec687 100644
--- a/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php
+++ b/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Tools\Console\Command;
diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php
index 82b56241d93..172bb59859f 100644
--- a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php
+++ b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php
@@ -1,25 +1,19 @@
.
- */
namespace Doctrine\DBAL\Tools\Console\Command;
+use Doctrine\DBAL\Platforms\Keywords\DB2Keywords;
+use Doctrine\DBAL\Platforms\Keywords\MySQL57Keywords;
+use Doctrine\DBAL\Platforms\Keywords\MySQLKeywords;
+use Doctrine\DBAL\Platforms\Keywords\OracleKeywords;
+use Doctrine\DBAL\Platforms\Keywords\PostgreSQL100Keywords;
+use Doctrine\DBAL\Platforms\Keywords\PostgreSQL94Keywords;
+use Doctrine\DBAL\Platforms\Keywords\PostgreSQLKeywords;
use Doctrine\DBAL\Platforms\Keywords\ReservedKeywordsValidator;
+use Doctrine\DBAL\Platforms\Keywords\SQLAnywhereKeywords;
+use Doctrine\DBAL\Platforms\Keywords\SQLiteKeywords;
+use Doctrine\DBAL\Platforms\Keywords\SQLServer2012Keywords;
+use Doctrine\DBAL\Platforms\Keywords\SQLServerKeywords;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -31,25 +25,20 @@
class ReservedWordsCommand extends Command
{
/**
- * @var array
+ * @var string[]
*/
private $keywordListClasses = [
- 'mysql' => 'Doctrine\DBAL\Platforms\Keywords\MySQLKeywords',
- 'mysql57' => 'Doctrine\DBAL\Platforms\Keywords\MySQL57Keywords',
- 'sqlserver' => 'Doctrine\DBAL\Platforms\Keywords\SQLServerKeywords',
- 'sqlserver2005' => 'Doctrine\DBAL\Platforms\Keywords\SQLServer2005Keywords',
- 'sqlserver2008' => 'Doctrine\DBAL\Platforms\Keywords\SQLServer2008Keywords',
- 'sqlserver2012' => 'Doctrine\DBAL\Platforms\Keywords\SQLServer2012Keywords',
- 'sqlite' => 'Doctrine\DBAL\Platforms\Keywords\SQLiteKeywords',
- 'pgsql' => 'Doctrine\DBAL\Platforms\Keywords\PostgreSQLKeywords',
- 'pgsql91' => 'Doctrine\DBAL\Platforms\Keywords\PostgreSQL91Keywords',
- 'pgsql92' => 'Doctrine\DBAL\Platforms\Keywords\PostgreSQL92Keywords',
- 'oracle' => 'Doctrine\DBAL\Platforms\Keywords\OracleKeywords',
- 'db2' => 'Doctrine\DBAL\Platforms\Keywords\DB2Keywords',
- 'sqlanywhere' => 'Doctrine\DBAL\Platforms\Keywords\SQLAnywhereKeywords',
- 'sqlanywhere11' => 'Doctrine\DBAL\Platforms\Keywords\SQLAnywhere11Keywords',
- 'sqlanywhere12' => 'Doctrine\DBAL\Platforms\Keywords\SQLAnywhere12Keywords',
- 'sqlanywhere16' => 'Doctrine\DBAL\Platforms\Keywords\SQLAnywhere16Keywords',
+ 'db2' => DB2Keywords::class,
+ 'mysql' => MySQLKeywords::class,
+ 'mysql57' => MySQL57Keywords::class,
+ 'oracle' => OracleKeywords::class,
+ 'pgsql' => PostgreSQLKeywords::class,
+ 'pgsql94' => PostgreSQL94Keywords::class,
+ 'pgsql100' => PostgreSQL100Keywords::class,
+ 'sqlanywhere' => SQLAnywhereKeywords::class,
+ 'sqlite' => SQLiteKeywords::class,
+ 'sqlserver' => SQLServerKeywords::class,
+ 'sqlserver2012' => SQLServer2012Keywords::class,
];
/**
@@ -97,17 +86,13 @@ protected function configure()
* mysql
* mysql57
* pgsql
- * pgsql92
+ * pgsql94
+ * pgsql100
* sqlite
* oracle
* sqlserver
- * sqlserver2005
- * sqlserver2008
* sqlserver2012
* sqlanywhere
- * sqlanywhere11
- * sqlanywhere12
- * sqlanywhere16
* db2 (Not checked by default)
EOT
);
@@ -123,22 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$keywordLists = (array) $input->getOption('list');
if ( ! $keywordLists) {
- $keywordLists = [
- 'mysql',
- 'mysql57',
- 'pgsql',
- 'pgsql92',
- 'sqlite',
- 'oracle',
- 'sqlserver',
- 'sqlserver2005',
- 'sqlserver2008',
- 'sqlserver2012',
- 'sqlanywhere',
- 'sqlanywhere11',
- 'sqlanywhere12',
- 'sqlanywhere16',
- ];
+ $keywordLists = array_keys($this->keywordListClasses);
}
$keywords = [];
diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php
index 27982d08950..54be180c470 100644
--- a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php
+++ b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Tools\Console\Command;
diff --git a/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php b/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php
index 61412a7cc5a..69098e2ea8e 100644
--- a/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php
+++ b/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Tools\Console;
@@ -24,7 +7,7 @@
use Doctrine\DBAL\Tools\Console\Command\ReservedWordsCommand;
use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand;
use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper;
-use Doctrine\DBAL\Version;
+use PackageVersions\Versions;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Helper\HelperSet;
@@ -57,7 +40,7 @@ public static function createHelperSet(Connection $connection)
*/
public static function run(HelperSet $helperSet, $commands = [])
{
- $cli = new Application('Doctrine Command Line Interface', Version::VERSION);
+ $cli = new Application('Doctrine Command Line Interface', Versions::getVersion('doctrine/dbal'));
$cli->setCatchExceptions(true);
$cli->setHelperSet($helperSet);
diff --git a/lib/Doctrine/DBAL/Tools/Console/Helper/ConnectionHelper.php b/lib/Doctrine/DBAL/Tools/Console/Helper/ConnectionHelper.php
index 1331c2baea4..f85162139a8 100644
--- a/lib/Doctrine/DBAL/Tools/Console/Helper/ConnectionHelper.php
+++ b/lib/Doctrine/DBAL/Tools/Console/Helper/ConnectionHelper.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Tools\Console\Helper;
diff --git a/lib/Doctrine/DBAL/Types/ArrayType.php b/lib/Doctrine/DBAL/Types/ArrayType.php
index 7fc4fcc9be6..c3f4b6bd631 100644
--- a/lib/Doctrine/DBAL/Types/ArrayType.php
+++ b/lib/Doctrine/DBAL/Types/ArrayType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/BigIntType.php b/lib/Doctrine/DBAL/Types/BigIntType.php
index 9a2b42953ad..d579af34ad5 100644
--- a/lib/Doctrine/DBAL/Types/BigIntType.php
+++ b/lib/Doctrine/DBAL/Types/BigIntType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/BinaryType.php b/lib/Doctrine/DBAL/Types/BinaryType.php
index 08dd7f74169..84fb71bbbfa 100644
--- a/lib/Doctrine/DBAL/Types/BinaryType.php
+++ b/lib/Doctrine/DBAL/Types/BinaryType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/BlobType.php b/lib/Doctrine/DBAL/Types/BlobType.php
index 84ee48af83e..dafe9917dc4 100644
--- a/lib/Doctrine/DBAL/Types/BlobType.php
+++ b/lib/Doctrine/DBAL/Types/BlobType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/BooleanType.php b/lib/Doctrine/DBAL/Types/BooleanType.php
index 748f7f52942..77dc9eba617 100644
--- a/lib/Doctrine/DBAL/Types/BooleanType.php
+++ b/lib/Doctrine/DBAL/Types/BooleanType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/ConversionException.php b/lib/Doctrine/DBAL/Types/ConversionException.php
index df2eb74a38f..0b23a4b0dd2 100644
--- a/lib/Doctrine/DBAL/Types/ConversionException.php
+++ b/lib/Doctrine/DBAL/Types/ConversionException.php
@@ -1,32 +1,5 @@
.
- */
-/**
- * Conversion Exception is thrown when the database to PHP conversion fails.
- *
- * @link www.doctrine-project.org
- * @since 2.0
- * @author Benjamin Eberlei
- * @author Guilherme Blanco
- * @author Jonathan Wage
- * @author Roman Borschel
- */
namespace Doctrine\DBAL\Types;
use function get_class;
@@ -38,6 +11,16 @@
use function strlen;
use function substr;
+/**
+ * Conversion Exception is thrown when the database to PHP conversion fails.
+ *
+ * @link www.doctrine-project.org
+ * @since 2.0
+ * @author Benjamin Eberlei
+ * @author Guilherme Blanco
+ * @author Jonathan Wage
+ * @author Roman Borschel
+ */
class ConversionException extends \Doctrine\DBAL\DBALException
{
/**
diff --git a/lib/Doctrine/DBAL/Types/DateImmutableType.php b/lib/Doctrine/DBAL/Types/DateImmutableType.php
index 8b9a91d7d32..9438efd9781 100644
--- a/lib/Doctrine/DBAL/Types/DateImmutableType.php
+++ b/lib/Doctrine/DBAL/Types/DateImmutableType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/DateTimeImmutableType.php b/lib/Doctrine/DBAL/Types/DateTimeImmutableType.php
index b8564fcddc3..33a6841c9e2 100644
--- a/lib/Doctrine/DBAL/Types/DateTimeImmutableType.php
+++ b/lib/Doctrine/DBAL/Types/DateTimeImmutableType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/DateTimeType.php b/lib/Doctrine/DBAL/Types/DateTimeType.php
index 3cb76ee5b54..57db8afa9c8 100644
--- a/lib/Doctrine/DBAL/Types/DateTimeType.php
+++ b/lib/Doctrine/DBAL/Types/DateTimeType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/DateTimeTzImmutableType.php b/lib/Doctrine/DBAL/Types/DateTimeTzImmutableType.php
index 91f3eda75de..78111f09b33 100644
--- a/lib/Doctrine/DBAL/Types/DateTimeTzImmutableType.php
+++ b/lib/Doctrine/DBAL/Types/DateTimeTzImmutableType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/DateTimeTzType.php b/lib/Doctrine/DBAL/Types/DateTimeTzType.php
index f731baf141d..8242819eebc 100644
--- a/lib/Doctrine/DBAL/Types/DateTimeTzType.php
+++ b/lib/Doctrine/DBAL/Types/DateTimeTzType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/DateType.php b/lib/Doctrine/DBAL/Types/DateType.php
index e3ed6a9e71e..8794706c4ce 100644
--- a/lib/Doctrine/DBAL/Types/DateType.php
+++ b/lib/Doctrine/DBAL/Types/DateType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/DecimalType.php b/lib/Doctrine/DBAL/Types/DecimalType.php
index 42c05d69a71..45a8e233f02 100644
--- a/lib/Doctrine/DBAL/Types/DecimalType.php
+++ b/lib/Doctrine/DBAL/Types/DecimalType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/FloatType.php b/lib/Doctrine/DBAL/Types/FloatType.php
index 87f9c32ae1a..ea1dc3b9ad3 100644
--- a/lib/Doctrine/DBAL/Types/FloatType.php
+++ b/lib/Doctrine/DBAL/Types/FloatType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/GuidType.php b/lib/Doctrine/DBAL/Types/GuidType.php
index 761d58a8e85..c522aa8ca50 100644
--- a/lib/Doctrine/DBAL/Types/GuidType.php
+++ b/lib/Doctrine/DBAL/Types/GuidType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/IntegerType.php b/lib/Doctrine/DBAL/Types/IntegerType.php
index 3c83341ded0..60b183a009a 100644
--- a/lib/Doctrine/DBAL/Types/IntegerType.php
+++ b/lib/Doctrine/DBAL/Types/IntegerType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/JsonArrayType.php b/lib/Doctrine/DBAL/Types/JsonArrayType.php
index 5650eb51856..0e62688251b 100644
--- a/lib/Doctrine/DBAL/Types/JsonArrayType.php
+++ b/lib/Doctrine/DBAL/Types/JsonArrayType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/JsonType.php b/lib/Doctrine/DBAL/Types/JsonType.php
index 6395332c682..e7f0ed0869d 100644
--- a/lib/Doctrine/DBAL/Types/JsonType.php
+++ b/lib/Doctrine/DBAL/Types/JsonType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/ObjectType.php b/lib/Doctrine/DBAL/Types/ObjectType.php
index 95fe84a5a19..469aa8c2cb5 100644
--- a/lib/Doctrine/DBAL/Types/ObjectType.php
+++ b/lib/Doctrine/DBAL/Types/ObjectType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/SimpleArrayType.php b/lib/Doctrine/DBAL/Types/SimpleArrayType.php
index fb01479e322..8059ef3490f 100644
--- a/lib/Doctrine/DBAL/Types/SimpleArrayType.php
+++ b/lib/Doctrine/DBAL/Types/SimpleArrayType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/SmallIntType.php b/lib/Doctrine/DBAL/Types/SmallIntType.php
index 1a2abdbe062..4fc2ab96211 100644
--- a/lib/Doctrine/DBAL/Types/SmallIntType.php
+++ b/lib/Doctrine/DBAL/Types/SmallIntType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/StringType.php b/lib/Doctrine/DBAL/Types/StringType.php
index 39bd32dbc8e..e56569c4644 100644
--- a/lib/Doctrine/DBAL/Types/StringType.php
+++ b/lib/Doctrine/DBAL/Types/StringType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/TextType.php b/lib/Doctrine/DBAL/Types/TextType.php
index bd72355464d..19bb875439d 100644
--- a/lib/Doctrine/DBAL/Types/TextType.php
+++ b/lib/Doctrine/DBAL/Types/TextType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/TimeImmutableType.php b/lib/Doctrine/DBAL/Types/TimeImmutableType.php
index 118d80ea8df..8e43e18f934 100644
--- a/lib/Doctrine/DBAL/Types/TimeImmutableType.php
+++ b/lib/Doctrine/DBAL/Types/TimeImmutableType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/TimeType.php b/lib/Doctrine/DBAL/Types/TimeType.php
index 639533fad5c..b9a5b66cd8a 100644
--- a/lib/Doctrine/DBAL/Types/TimeType.php
+++ b/lib/Doctrine/DBAL/Types/TimeType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/Type.php b/lib/Doctrine/DBAL/Types/Type.php
index 453631e0aaa..7fa7aea53a5 100644
--- a/lib/Doctrine/DBAL/Types/Type.php
+++ b/lib/Doctrine/DBAL/Types/Type.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php b/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php
index f0e8ff84482..a8bf8f2f090 100644
--- a/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php
+++ b/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Types/VarDateTimeType.php b/lib/Doctrine/DBAL/Types/VarDateTimeType.php
index b55e0b05b3e..2396230c3b5 100644
--- a/lib/Doctrine/DBAL/Types/VarDateTimeType.php
+++ b/lib/Doctrine/DBAL/Types/VarDateTimeType.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL\Types;
diff --git a/lib/Doctrine/DBAL/Version.php b/lib/Doctrine/DBAL/Version.php
deleted file mode 100644
index 5f22681e56a..00000000000
--- a/lib/Doctrine/DBAL/Version.php
+++ /dev/null
@@ -1,57 +0,0 @@
-.
- */
-
-namespace Doctrine\DBAL;
-
-use function str_replace;
-use function strtolower;
-use function version_compare;
-
-/**
- * Class to store and retrieve the version of Doctrine.
- *
- * @link www.doctrine-project.org
- * @since 2.0
- * @author Benjamin Eberlei
- * @author Guilherme Blanco
- * @author Jonathan Wage
- * @author Roman Borschel
- */
-class Version
-{
- /**
- * Current Doctrine Version.
- */
- public const VERSION = '2.8.0-DEV';
-
- /**
- * Compares a Doctrine version with the current one.
- *
- * @param string $version The Doctrine version to compare to.
- *
- * @return int -1 if older, 0 if it is the same, 1 if version passed as argument is newer.
- */
- public static function compare($version)
- {
- $currentVersion = str_replace(' ', '', strtolower(self::VERSION));
- $version = str_replace(' ', '', $version);
-
- return version_compare($version, $currentVersion);
- }
-}
diff --git a/lib/Doctrine/DBAL/VersionAwarePlatformDriver.php b/lib/Doctrine/DBAL/VersionAwarePlatformDriver.php
index 53e2d3ab781..45eb8a91fa2 100644
--- a/lib/Doctrine/DBAL/VersionAwarePlatformDriver.php
+++ b/lib/Doctrine/DBAL/VersionAwarePlatformDriver.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\DBAL;
diff --git a/tests/Doctrine/Tests/DBAL/ConfigurationTest.php b/tests/Doctrine/Tests/DBAL/ConfigurationTest.php
index 4379b3b35a9..bb7bf98c310 100644
--- a/tests/Doctrine/Tests/DBAL/ConfigurationTest.php
+++ b/tests/Doctrine/Tests/DBAL/ConfigurationTest.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\Tests\DBAL;
diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php
index b71e10f80ce..48095d7dd7b 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php
@@ -4,6 +4,7 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Platforms\PostgreSQL100Platform;
+use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Schema\PostgreSqlSchemaManager;
@@ -55,21 +56,15 @@ protected function createSchemaManager(Connection $connection)
protected function getDatabasePlatformsForVersions()
{
- return array(
- array('9.0.9', 'Doctrine\DBAL\Platforms\PostgreSqlPlatform'),
- array('9.1', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'),
- array('9.1.0', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'),
- array('9.1.1', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'),
- array('9.1.9', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'),
- array('9.2', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'),
- array('9.2.0', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'),
- array('9.2.1', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'),
- array('9.3.6', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'),
- array('9.4', 'Doctrine\DBAL\Platforms\PostgreSQL94Platform'),
- array('9.4.0', 'Doctrine\DBAL\Platforms\PostgreSQL94Platform'),
- array('9.4.1', 'Doctrine\DBAL\Platforms\PostgreSQL94Platform'),
- array('10', PostgreSQL100Platform::class),
- );
+ return [
+ ['9.3', PostgreSqlPlatform::class],
+ ['9.3.0', PostgreSqlPlatform::class],
+ ['9.3.6', PostgreSqlPlatform::class],
+ ['9.4', PostgreSQL94Platform::class],
+ ['9.4.0', PostgreSQL94Platform::class],
+ ['9.4.1', PostgreSQL94Platform::class],
+ ['10', PostgreSQL100Platform::class],
+ ];
}
protected function getExceptionConversionData()
diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php
index f2b13c3c1c9..efa3a97a2ab 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php
@@ -3,7 +3,7 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
-use Doctrine\DBAL\Platforms\SQLAnywhere12Platform;
+use Doctrine\DBAL\Platforms\SQLAnywherePlatform;
use Doctrine\DBAL\Schema\SQLAnywhereSchemaManager;
class AbstractSQLAnywhereDriverTest extends AbstractDriverTest
@@ -15,7 +15,7 @@ protected function createDriver()
protected function createPlatform()
{
- return new SQLAnywhere12Platform();
+ return new SQLAnywherePlatform();
}
protected function createSchemaManager(Connection $connection)
@@ -25,37 +25,15 @@ protected function createSchemaManager(Connection $connection)
protected function getDatabasePlatformsForVersions()
{
- return array(
- array('10', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'),
- array('10.0', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'),
- array('10.0.0', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'),
- array('10.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'),
- array('10.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'),
- array('10.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'),
- array('11', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'),
- array('11.0', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'),
- array('11.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'),
- array('11.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'),
- array('11.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'),
- array('11.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'),
- array('12', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('12.0', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('12.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('12.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('12.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('12.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('13', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('14', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('15', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('15.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('16', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'),
- array('16.0', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'),
- array('16.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'),
- array('16.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'),
- array('16.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'),
- array('16.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'),
- array('17', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'),
- );
+ return [
+ ['16', SQLAnywherePlatform::class],
+ ['16.0', SQLAnywherePlatform::class],
+ ['16.0.0', SQLAnywherePlatform::class],
+ ['16.0.0.0', SQLAnywherePlatform::class],
+ ['16.1.2.3', SQLAnywherePlatform::class],
+ ['16.9.9.9', SQLAnywherePlatform::class],
+ ['17', SQLAnywherePlatform::class],
+ ];
}
protected function getExceptionConversionData()
diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php
index 35d2d721a51..4d9f36ade67 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php
@@ -3,7 +3,8 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
-use Doctrine\DBAL\Platforms\SQLServer2008Platform;
+use Doctrine\DBAL\Platforms\SQLServer2012Platform;
+use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Schema\SQLServerSchemaManager;
class AbstractSQLServerDriverTest extends AbstractDriverTest
@@ -15,7 +16,7 @@ protected function createDriver()
protected function createPlatform()
{
- return new SQLServer2008Platform();
+ return new SQLServerPlatform();
}
protected function createSchemaManager(Connection $connection)
@@ -25,33 +26,25 @@ protected function createSchemaManager(Connection $connection)
protected function getDatabasePlatformsForVersions()
{
- return array(
- array('9', 'Doctrine\DBAL\Platforms\SQLServerPlatform'),
- array('9.00', 'Doctrine\DBAL\Platforms\SQLServerPlatform'),
- array('9.00.0', 'Doctrine\DBAL\Platforms\SQLServerPlatform'),
- array('9.00.1398', 'Doctrine\DBAL\Platforms\SQLServerPlatform'),
- array('9.00.1398.99', 'Doctrine\DBAL\Platforms\SQLServerPlatform'),
- array('9.00.1399', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'),
- array('9.00.1399.0', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'),
- array('9.00.1399.99', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'),
- array('9.00.1400', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'),
- array('9.10', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'),
- array('9.10.9999', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'),
- array('10.00.1599', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'),
- array('10.00.1599.99', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'),
- array('10.00.1600', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'),
- array('10.00.1600.0', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'),
- array('10.00.1600.99', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'),
- array('10.00.1601', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'),
- array('10.10', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'),
- array('10.10.9999', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'),
- array('11.00.2099', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'),
- array('11.00.2099.99', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'),
- array('11.00.2100', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'),
- array('11.00.2100.0', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'),
- array('11.00.2100.99', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'),
- array('11.00.2101', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'),
- array('12', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'),
- );
+ return [
+ ['10', SQLServerPlatform::class],
+ ['10.00', SQLServerPlatform::class],
+ ['10.00.0', SQLServerPlatform::class],
+ ['10.00.1599', SQLServerPlatform::class],
+ ['10.00.1599.99', SQLServerPlatform::class],
+ ['10.00.1600', SQLServerPlatform::class],
+ ['10.00.1600.0', SQLServerPlatform::class],
+ ['10.00.1600.99', SQLServerPlatform::class],
+ ['10.00.1601', SQLServerPlatform::class],
+ ['10.10', SQLServerPlatform::class],
+ ['10.10.9999', SQLServerPlatform::class],
+ ['11.00.2099', SQLServerPlatform::class],
+ ['11.00.2099.99', SQLServerPlatform::class],
+ ['11.00.2100', SQLServer2012Platform::class],
+ ['11.00.2100.0', SQLServer2012Platform::class],
+ ['11.00.2100.99', SQLServer2012Platform::class],
+ ['11.00.2101', SQLServer2012Platform::class],
+ ['12', SQLServer2012Platform::class],
+ ];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/DrizzlePDOMySql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/DrizzlePDOMySql/DriverTest.php
deleted file mode 100644
index 004043c2051..00000000000
--- a/tests/Doctrine/Tests/DBAL/Driver/DrizzlePDOMySql/DriverTest.php
+++ /dev/null
@@ -1,46 +0,0 @@
-driver->getName());
- }
-
- public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion()
- {
- $this->markTestSkipped('This test does not work on Drizzle as it is not version aware.');
- }
-
- protected function createDriver()
- {
- return new Driver();
- }
-
- protected function createPlatform()
- {
- return new DrizzlePlatform();
- }
-
- protected function createSchemaManager(Connection $connection)
- {
- return new DrizzleSchemaManager($connection);
- }
-
- protected function getDatabasePlatformsForVersions() : array
- {
- return [
- ['foo', 'Doctrine\DBAL\Platforms\DrizzlePlatform'],
- ['bar', 'Doctrine\DBAL\Platforms\DrizzlePlatform'],
- ['baz', 'Doctrine\DBAL\Platforms\DrizzlePlatform'],
- ];
- }
-}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php
index 1dec0608eba..95cf63176ee 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php
@@ -21,7 +21,7 @@ class MysqliConnectionTest extends DbalFunctionalTestCase
protected function setUp()
{
- if ( ! extension_loaded('mysqli')) {
+ if (! extension_loaded('mysqli')) {
$this->markTestSkipped('mysqli is not installed.');
}
@@ -50,7 +50,7 @@ public function testRestoresErrorHandlerOnException()
new MysqliConnection(['host' => '255.255.255.255'], 'user', 'pass');
self::fail('An exception was supposed to be raised');
} catch (MysqliException $e) {
- self::assertSame('Network is unreachable', $e->getMessage());
+ // Do nothing
}
self::assertSame($handler, set_error_handler($default_handler), 'Restoring error handler failed.');
diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOIbm/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOIbm/DriverTest.php
deleted file mode 100644
index 6361f05575c..00000000000
--- a/tests/Doctrine/Tests/DBAL/Driver/PDOIbm/DriverTest.php
+++ /dev/null
@@ -1,19 +0,0 @@
-driver->getName());
- }
-
- protected function createDriver()
- {
- return new Driver();
- }
-}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php
index 6fd187e3d28..45e9c530a11 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php
@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Driver\PDOPgSql;
+use Doctrine\DBAL\Driver\PDOConnection;
use Doctrine\DBAL\Driver\PDOPgSql\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractPostgreSQLDriverTest;
use PDO;
@@ -31,10 +32,10 @@ public function testConnectionDisablesPreparesOnPhp56()
$GLOBALS['db_password']
);
- self::assertInstanceOf('Doctrine\DBAL\Driver\PDOConnection', $connection);
+ self::assertInstanceOf(PDOConnection::class, $connection);
try {
- self::assertTrue($connection->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES));
+ self::assertTrue($connection->getWrappedConnection()->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES));
} catch (PDOException $ignored) {
/** @link https://bugs.php.net/bug.php?id=68371 */
$this->markTestIncomplete('See https://bugs.php.net/bug.php?id=68371');
@@ -58,10 +59,13 @@ public function testConnectionDoesNotDisablePreparesOnPhp56WhenAttributeDefined(
array(PDO::PGSQL_ATTR_DISABLE_PREPARES => false)
);
- self::assertInstanceOf('Doctrine\DBAL\Driver\PDOConnection', $connection);
+ self::assertInstanceOf(PDOConnection::class, $connection);
try {
- self::assertNotSame(true, $connection->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES));
+ self::assertNotSame(
+ true,
+ $connection->getWrappedConnection()->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES)
+ );
} catch (PDOException $ignored) {
/** @link https://bugs.php.net/bug.php?id=68371 */
$this->markTestIncomplete('See https://bugs.php.net/bug.php?id=68371');
@@ -85,10 +89,10 @@ public function testConnectionDisablePreparesOnPhp56WhenDisablePreparesIsExplici
array(PDO::PGSQL_ATTR_DISABLE_PREPARES => true)
);
- self::assertInstanceOf('Doctrine\DBAL\Driver\PDOConnection', $connection);
+ self::assertInstanceOf(PDOConnection::class, $connection);
try {
- self::assertTrue($connection->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES));
+ self::assertTrue($connection->getWrappedConnection()->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES));
} catch (PDOException $ignored) {
/** @link https://bugs.php.net/bug.php?id=68371 */
$this->markTestIncomplete('See https://bugs.php.net/bug.php?id=68371');
diff --git a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php
index b242ea49153..e682ad831d6 100644
--- a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php
@@ -3,7 +3,6 @@
namespace Doctrine\Tests\DBAL;
use Doctrine\DBAL\DBALException;
-use Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver as DrizzlePDOMySqlDriver;
use Doctrine\DBAL\Driver\PDOMySQL\Driver as PDOMySQLDriver;
use Doctrine\DBAL\Driver\PDOSqlite\Driver as PDOSqliteDriver;
use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver;
@@ -274,17 +273,17 @@ public function databaseUrls()
],
],
'simple URL with fallthrough scheme containing underscores fails' => [
- 'drizzle_pdo_mysql://foo:bar@localhost/baz',
+ 'pdo_mysql://foo:bar@localhost/baz',
false,
],
'simple URL with fallthrough scheme containing dashes works' => [
- 'drizzle-pdo-mysql://foo:bar@localhost/baz',
+ 'pdo-mysql://foo:bar@localhost/baz',
[
'user' => 'foo',
'password' => 'bar',
'host' => 'localhost',
'dbname' => 'baz',
- 'driver' => DrizzlePDOMySqlDriver::class,
+ 'driver' => PDOMySQLDriver::class,
],
],
'simple URL with percent encoding' => [
diff --git a/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php b/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php
index 9984e3d0223..691ba9d1c42 100644
--- a/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\Tests\DBAL\Exception;
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php
index 29f18f8c78f..359e81b70d9 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php
@@ -72,7 +72,9 @@ public function testThrowsWrappedExceptionOnPrepare()
// Emulated prepared statements have to be disabled for this test
// so that PDO actually communicates with the database server to check the query.
- $this->driverConnection->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
+ $this->driverConnection
+ ->getWrappedConnection()
+ ->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
$this->driverConnection->prepare('foo');
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php
index 6c9ea327a62..637b8539b5a 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php
@@ -25,7 +25,7 @@ protected function setUp()
public function testFailureToPrepareResultsInException()
{
// use the driver connection directly to avoid having exception wrapped
- $stmt = $this->_conn->getWrappedConnection()->prepare(null);
+ $stmt = $this->_conn->getWrappedConnection()->prepare('');
// it's impossible to prepare the statement without bound variables for SQL Server,
// so the preparation happens before the first execution when variables are already in place
diff --git a/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php b/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php
index a8c73ce33c5..05ea871f360 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php
@@ -307,6 +307,7 @@ public function testConnectionExceptionSqLite($mode, $exceptionClass)
$table->addColumn('id', 'integer');
$this->expectException($exceptionClass);
+
foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) {
$conn->exec($sql);
}
@@ -330,10 +331,6 @@ public function testConnectionException($params)
$this->markTestSkipped("Only skipped if platform is not sqlite");
}
- if ($this->_conn->getDatabasePlatform()->getName() == 'drizzle') {
- $this->markTestSkipped("Drizzle does not always support authentication");
- }
-
if ($this->_conn->getDatabasePlatform()->getName() == 'postgresql' && isset($params['password'])) {
$this->markTestSkipped("Does not work on Travis");
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php
deleted file mode 100644
index 5b63b363a51..00000000000
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php
+++ /dev/null
@@ -1,47 +0,0 @@
-addColumn('id', 'integer');
- $table->addColumn('column_varbinary', 'binary', array());
- $table->addColumn('column_binary', 'binary', array('fixed' => true));
- $table->setPrimaryKey(array('id'));
-
- $this->_sm->createTable($table);
-
- $table = $this->_sm->listTableDetails($tableName);
-
- self::assertInstanceOf('Doctrine\DBAL\Types\BinaryType', $table->getColumn('column_varbinary')->getType());
- self::assertFalse($table->getColumn('column_varbinary')->getFixed());
-
- self::assertInstanceOf('Doctrine\DBAL\Types\BinaryType', $table->getColumn('column_binary')->getType());
- self::assertFalse($table->getColumn('column_binary')->getFixed());
- }
-
- public function testColumnCollation()
- {
- $table = new Table('test_collation');
- $table->addOption('collate', $collation = 'utf8_unicode_ci');
- $table->addColumn('id', 'integer');
- $table->addColumn('text', 'text');
- $table->addColumn('foo', 'text')->setPlatformOption('collation', 'utf8_swedish_ci');
- $table->addColumn('bar', 'text')->setPlatformOption('collation', 'utf8_general_ci');
- $this->_sm->dropAndCreateTable($table);
-
- $columns = $this->_sm->listTableColumns('test_collation');
-
- self::assertArrayNotHasKey('collation', $columns['id']->getPlatformOptions());
- self::assertEquals('utf8_unicode_ci', $columns['text']->getPlatformOption('collation'));
- self::assertEquals('utf8_swedish_ci', $columns['foo']->getPlatformOption('collation'));
- self::assertEquals('utf8_general_ci', $columns['bar']->getPlatformOption('collation'));
- }
-}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
index c7b4aed39e9..e6d41b17b19 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
@@ -942,7 +942,7 @@ protected function createTestTable($name = 'test_table', $data = array())
protected function getTestTable($name, $options=array())
{
- $table = new Table($name, array(), array(), array(), false, $options);
+ $table = new Table($name, array(), array(), array(), array(), $options);
$table->setSchemaConfig($this->_sm->createSchemaConfig());
$table->addColumn('id', 'integer', array('notnull' => true));
$table->setPrimaryKey(array('id'));
@@ -953,7 +953,7 @@ protected function getTestTable($name, $options=array())
protected function getTestCompositeTable($name)
{
- $table = new Table($name, array(), array(), array(), false, array());
+ $table = new Table($name, array(), array(), array(), array(), array());
$table->setSchemaConfig($this->_sm->createSchemaConfig());
$table->addColumn('id', 'integer', array('notnull' => true));
$table->addColumn('other_id', 'integer', array('notnull' => true));
@@ -965,12 +965,15 @@ protected function getTestCompositeTable($name)
protected function assertHasTable($tables, $tableName)
{
$foundTable = false;
+
foreach ($tables as $table) {
self::assertInstanceOf('Doctrine\DBAL\Schema\Table', $table, 'No Table instance was found in tables array.');
+
if (strtolower($table->getName()) == 'list_tables_test_new_name') {
$foundTable = true;
}
}
+
self::assertTrue($foundTable, "Could not find new table");
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php
index 70210133b1f..8588a16ba6e 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php
@@ -38,7 +38,9 @@ protected function setUp()
protected function tearDown()
{
if ($this->running) {
- $this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
+ $this->_conn->getWrappedConnection()
+ ->getWrappedConnection()
+ ->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
}
parent::tearDown();
@@ -72,7 +74,9 @@ public function testBooleanConversionBoolParamRealPrepares()
public function testBooleanConversionBoolParamEmulatedPrepares()
{
- $this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
+ $this->_conn->getWrappedConnection()
+ ->getWrappedConnection()
+ ->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$platform = $this->_conn->getDatabasePlatform();
@@ -96,7 +100,9 @@ public function testBooleanConversionNullParamEmulatedPrepares(
$statementValue,
$databaseConvertedValue
) {
- $this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
+ $this->_conn->getWrappedConnection()
+ ->getWrappedConnection()
+ ->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$platform = $this->_conn->getDatabasePlatform();
@@ -120,7 +126,9 @@ public function testBooleanConversionNullParamEmulatedPreparesWithBooleanTypeInB
$statementValue,
$databaseConvertedValue
) {
- $this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
+ $this->_conn->getWrappedConnection()
+ ->getWrappedConnection()
+ ->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$platform = $this->_conn->getDatabasePlatform();
diff --git a/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php b/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php
index a652d1aac9f..ac1e7549466 100644
--- a/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php
+++ b/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php
@@ -21,8 +21,8 @@ public function testLoggedQuery()
array(
1 => array(
'sql' => 'SELECT column FROM table',
- 'params' => null,
- 'types' => null,
+ 'params' => [],
+ 'types' => [],
'executionMS' => 0,
),
),
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
index 270ebf947e5..297b441b6ef 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
@@ -12,6 +12,7 @@
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
+use Doctrine\DBAL\Schema\UniqueConstraint;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\Types\CommentedType;
use function get_class;
@@ -191,7 +192,7 @@ abstract public function getGenerateTableWithMultiColumnUniqueIndexSql();
public function testGeneratesIndexCreationSql()
{
- $indexDef = new \Doctrine\DBAL\Schema\Index('my_idx', array('user_name', 'last_login'));
+ $indexDef = new Index('my_idx', array('user_name', 'last_login'));
self::assertEquals(
$this->getGenerateIndexSql(),
@@ -203,7 +204,7 @@ abstract public function getGenerateIndexSql();
public function testGeneratesUniqueIndexCreationSql()
{
- $indexDef = new \Doctrine\DBAL\Schema\Index('index_name', array('test', 'test2'), true);
+ $indexDef = new Index('index_name', array('test', 'test2'), true);
$sql = $this->_platform->getCreateIndexSQL($indexDef, 'test');
self::assertEquals($this->getGenerateUniqueIndexSql(), $sql);
@@ -214,8 +215,8 @@ abstract public function getGenerateUniqueIndexSql();
public function testGeneratesPartialIndexesSqlOnlyWhenSupportingPartialIndexes()
{
$where = 'test IS NULL AND test2 IS NOT NULL';
- $indexDef = new \Doctrine\DBAL\Schema\Index('name', array('test', 'test2'), false, false, array(), array('where' => $where));
- $uniqueIndex = new \Doctrine\DBAL\Schema\Index('name', array('test', 'test2'), true, false, array(), array('where' => $where));
+ $indexDef = new Index('name', array('test', 'test2'), false, false, array(), array('where' => $where));
+ $uniqueConstraint = new UniqueConstraint('name', array('test', 'test2'), array(), array());
$expected = ' WHERE ' . $where;
@@ -225,21 +226,21 @@ public function testGeneratesPartialIndexesSqlOnlyWhenSupportingPartialIndexes()
$actuals []= $this->_platform->getIndexDeclarationSQL('name', $indexDef);
}
- $actuals []= $this->_platform->getUniqueConstraintDeclarationSQL('name', $uniqueIndex);
- $actuals []= $this->_platform->getCreateIndexSQL($indexDef, 'table');
+ $uniqueConstraintSQL = $this->_platform->getUniqueConstraintDeclarationSQL('name', $uniqueConstraint);
+ $indexSQL = $this->_platform->getCreateIndexSQL($indexDef, 'table');
- foreach ($actuals as $actual) {
+ $this->assertStringEndsNotWith($expected, $uniqueConstraintSQL, 'WHERE clause should NOT be present');
if ($this->_platform->supportsPartialIndexes()) {
- self::assertStringEndsWith($expected, $actual, 'WHERE clause should be present');
+ self::assertStringEndsWith($expected, $indexSQL, 'WHERE clause should be present');
} else {
- self::assertStringEndsNotWith($expected, $actual, 'WHERE clause should NOT be present');
- }
+ self::assertStringEndsNotWith($expected, $indexSQL, 'WHERE clause should NOT be present');
+
}
}
public function testGeneratesForeignKeyCreationSql()
{
- $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name_id'), 'other_table', array('id'), '');
+ $fk = new ForeignKeyConstraint(array('fk_name_id'), 'other_table', array('id'), '');
$sql = $this->_platform->getCreateForeignKeySQL($fk, 'test');
self::assertEquals($sql, $this->getGenerateForeignKeySql());
@@ -249,22 +250,22 @@ abstract public function getGenerateForeignKeySql();
public function testGeneratesConstraintCreationSql()
{
- $idx = new \Doctrine\DBAL\Schema\Index('constraint_name', array('test'), true, false);
+ $idx = new Index('constraint_name', array('test'), true, false);
$sql = $this->_platform->getCreateConstraintSQL($idx, 'test');
self::assertEquals($this->getGenerateConstraintUniqueIndexSql(), $sql);
- $pk = new \Doctrine\DBAL\Schema\Index('constraint_name', array('test'), true, true);
+ $pk = new Index('constraint_name', array('test'), true, true);
$sql = $this->_platform->getCreateConstraintSQL($pk, 'test');
self::assertEquals($this->getGenerateConstraintPrimaryIndexSql(), $sql);
- $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name'), 'foreign', array('id'), 'constraint_fk');
+ $fk = new ForeignKeyConstraint(array('fk_name'), 'foreign', array('id'), 'constraint_fk');
$sql = $this->_platform->getCreateConstraintSQL($fk, 'test');
self::assertEquals($this->getGenerateConstraintForeignKeySql($fk), $sql);
}
public function testGeneratesForeignKeySqlOnlyWhenSupportingForeignKeys()
{
- $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name'), 'foreign', array('id'), 'constraint_fk');
+ $fk = new ForeignKeyConstraint(array('fk_name'), 'foreign', array('id'), 'constraint_fk');
if ($this->_platform->supportsForeignKeyConstraints()) {
self::assertInternalType(
@@ -685,11 +686,11 @@ public function testQuotedColumnInForeignKeyPropagation()
*/
public function testQuotesReservedKeywordInUniqueConstraintDeclarationSQL()
{
- $index = new Index('select', array('foo'), true);
+ $constraint = new UniqueConstraint('select', array('foo'), array(), array());
self::assertSame(
$this->getQuotesReservedKeywordInUniqueConstraintDeclarationSQL(),
- $this->_platform->getUniqueConstraintDeclarationSQL('select', $index)
+ $this->_platform->getUniqueConstraintDeclarationSQL('select', $constraint)
);
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
index 206c571828b..d79f5c527c1 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
@@ -1364,7 +1364,7 @@ public function getReturnsForeignKeyReferentialActionSQL()
*/
protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL()
{
- return 'CONSTRAINT [select] UNIQUE (foo) WHERE foo IS NOT NULL';
+ return 'CONSTRAINT [select] UNIQUE (foo)';
}
/**
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL91PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL91PlatformTest.php
deleted file mode 100644
index 69ba94973f5..00000000000
--- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL91PlatformTest.php
+++ /dev/null
@@ -1,40 +0,0 @@
-_platform->supportsColumnCollation());
- }
-
- public function testColumnCollationDeclarationSQL() : void
- {
- self::assertSame(
- 'COLLATE "en_US.UTF-8"',
- $this->_platform->getColumnCollationDeclarationSQL('en_US.UTF-8')
- );
- }
-
- public function testGetCreateTableSQLWithColumnCollation() : void
- {
- $table = new Table('foo');
- $table->addColumn('no_collation', 'string');
- $table->addColumn('column_collation', 'string')->setPlatformOption('collation', 'en_US.UTF-8');
-
- self::assertSame(
- ['CREATE TABLE foo (no_collation VARCHAR(255) NOT NULL, column_collation VARCHAR(255) NOT NULL COLLATE "en_US.UTF-8")'],
- $this->_platform->getCreateTableSQL($table),
- 'Column "no_collation" will use the default collation from the table/database and "column_collation" overwrites the collation on this column'
- );
- }
-}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php
deleted file mode 100644
index 0189dbdfe36..00000000000
--- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php
+++ /dev/null
@@ -1,71 +0,0 @@
-_platform->hasNativeJsonType());
- }
-
- /**
- * @group DBAL-553
- */
- public function testReturnsJsonTypeDeclarationSQL()
- {
- self::assertSame('JSON', $this->_platform->getJsonTypeDeclarationSQL(array()));
- }
-
- public function testReturnsSmallIntTypeDeclarationSQL()
- {
- self::assertSame(
- 'SMALLSERIAL',
- $this->_platform->getSmallIntTypeDeclarationSQL(array('autoincrement' => true))
- );
-
- self::assertSame(
- 'SMALLINT',
- $this->_platform->getSmallIntTypeDeclarationSQL(array('autoincrement' => false))
- );
-
- self::assertSame(
- 'SMALLINT',
- $this->_platform->getSmallIntTypeDeclarationSQL(array())
- );
- }
-
- /**
- * @group DBAL-553
- */
- public function testInitializesJsonTypeMapping()
- {
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('json'));
- self::assertEquals(Type::JSON, $this->_platform->getDoctrineTypeMapping('json'));
- }
-
- /**
- * @group DBAL-1220
- */
- public function testReturnsCloseActiveDatabaseConnectionsSQL()
- {
- self::assertSame(
- "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'foo'",
- $this->_platform->getCloseActiveDatabaseConnectionsSQL('foo')
- );
- }
-}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php
index d566007afc2..3b307f7a0aa 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php
@@ -5,7 +5,7 @@
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Types\Type;
-class PostgreSQL94PlatformTest extends PostgreSQL92PlatformTest
+class PostgreSQL94PlatformTest extends PostgreSqlPlatformTest
{
/**
* {@inheritdoc}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
index 6db159df48e..6f0777a32f4 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
@@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Platforms;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
+use Doctrine\DBAL\Types\Type;
class PostgreSqlPlatformTest extends AbstractPostgreSqlPlatformTestCase
{
@@ -15,4 +16,66 @@ public function testSupportsPartialIndexes()
{
self::assertTrue($this->_platform->supportsPartialIndexes());
}
+
+ public function testColumnCollationDeclarationSQL()
+ {
+ self::assertEquals(
+ 'COLLATE "en_US.UTF-8"',
+ $this->_platform->getColumnCollationDeclarationSQL('en_US.UTF-8')
+ );
+ }
+
+ /**
+ * @group DBAL-553
+ */
+ public function testHasNativeJsonType()
+ {
+ self::assertTrue($this->_platform->hasNativeJsonType());
+ }
+
+ /**
+ * @group DBAL-553
+ */
+ public function testReturnsJsonTypeDeclarationSQL()
+ {
+ self::assertSame('JSON', $this->_platform->getJsonTypeDeclarationSQL([]));
+ }
+
+ public function testReturnsSmallIntTypeDeclarationSQL()
+ {
+ self::assertSame(
+ 'SMALLSERIAL',
+ $this->_platform->getSmallIntTypeDeclarationSQL(['autoincrement' => true])
+ );
+
+ self::assertSame(
+ 'SMALLINT',
+ $this->_platform->getSmallIntTypeDeclarationSQL(['autoincrement' => false])
+ );
+
+ self::assertSame(
+ 'SMALLINT',
+ $this->_platform->getSmallIntTypeDeclarationSQL([])
+ );
+ }
+
+ /**
+ * @group DBAL-553
+ */
+ public function testInitializesJsonTypeMapping()
+ {
+ self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('json'));
+ self::assertEquals(Type::JSON, $this->_platform->getDoctrineTypeMapping('json'));
+ }
+
+ /**
+ * @group DBAL-1220
+ */
+ public function testReturnsCloseActiveDatabaseConnectionsSQL()
+ {
+ self::assertSame(
+ "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'foo'",
+ $this->_platform->getCloseActiveDatabaseConnectionsSQL('foo')
+ );
+ }
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere11PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere11PlatformTest.php
deleted file mode 100644
index c59a9b1ac12..00000000000
--- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere11PlatformTest.php
+++ /dev/null
@@ -1,28 +0,0 @@
-markTestSkipped('This version of the platform now supports regular expressions.');
- }
-
- public function testGeneratesRegularExpressionSQLSnippet()
- {
- self::assertEquals('REGEXP', $this->_platform->getRegexpExpression());
- }
-}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere12PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere12PlatformTest.php
deleted file mode 100644
index 4c6763ae124..00000000000
--- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere12PlatformTest.php
+++ /dev/null
@@ -1,143 +0,0 @@
-markTestSkipped('This version of the platform now supports sequences.');
- }
-
- public function testSupportsSequences()
- {
- self::assertTrue($this->_platform->supportsSequences());
- }
-
- public function testGeneratesSequenceSqlCommands()
- {
- $sequence = new Sequence('myseq', 20, 1);
- self::assertEquals(
- 'CREATE SEQUENCE myseq INCREMENT BY 20 START WITH 1 MINVALUE 1',
- $this->_platform->getCreateSequenceSQL($sequence)
- );
- self::assertEquals(
- 'ALTER SEQUENCE myseq INCREMENT BY 20',
- $this->_platform->getAlterSequenceSQL($sequence)
- );
- self::assertEquals(
- 'DROP SEQUENCE myseq',
- $this->_platform->getDropSequenceSQL('myseq')
- );
- self::assertEquals(
- 'DROP SEQUENCE myseq',
- $this->_platform->getDropSequenceSQL($sequence)
- );
- self::assertEquals(
- "SELECT myseq.NEXTVAL",
- $this->_platform->getSequenceNextValSQL('myseq')
- );
- self::assertEquals(
- 'SELECT sequence_name, increment_by, start_with, min_value FROM SYS.SYSSEQUENCE',
- $this->_platform->getListSequencesSQL(null)
- );
- }
-
- public function testGeneratesDateTimeTzColumnTypeDeclarationSQL()
- {
- self::assertEquals(
- 'TIMESTAMP WITH TIME ZONE',
- $this->_platform->getDateTimeTzTypeDeclarationSQL(array(
- 'length' => 10,
- 'fixed' => true,
- 'unsigned' => true,
- 'autoincrement' => true
- ))
- );
- }
-
- public function testHasCorrectDateTimeTzFormatString()
- {
- self::assertEquals('Y-m-d H:i:s.uP', $this->_platform->getDateTimeTzFormatString());
- }
-
- public function testInitializesDateTimeTzTypeMapping()
- {
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('timestamp with time zone'));
- self::assertEquals('datetime', $this->_platform->getDoctrineTypeMapping('timestamp with time zone'));
- }
-
- public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL()
- {
- self::assertEquals(
- 'CREATE VIRTUAL UNIQUE CLUSTERED INDEX fooindex ON footable (a, b) WITH NULLS NOT DISTINCT FOR OLAP WORKLOAD',
- $this->_platform->getCreateIndexSQL(
- new Index(
- 'fooindex',
- array('a', 'b'),
- true,
- false,
- array('virtual', 'clustered', 'with_nulls_not_distinct', 'for_olap_workload')
- ),
- 'footable'
- )
- );
- self::assertEquals(
- 'CREATE VIRTUAL CLUSTERED INDEX fooindex ON footable (a, b) FOR OLAP WORKLOAD',
- $this->_platform->getCreateIndexSQL(
- new Index(
- 'fooindex',
- array('a', 'b'),
- false,
- false,
- array('virtual', 'clustered', 'with_nulls_not_distinct', 'for_olap_workload')
- ),
- 'footable'
- )
- );
-
- // WITH NULLS NOT DISTINCT clause not available on primary indexes.
- self::assertEquals(
- 'ALTER TABLE footable ADD PRIMARY KEY (a, b)',
- $this->_platform->getCreateIndexSQL(
- new Index(
- 'fooindex',
- array('a', 'b'),
- false,
- true,
- array('with_nulls_not_distinct')
- ),
- 'footable'
- )
- );
-
- // WITH NULLS NOT DISTINCT clause not available on non-unique indexes.
- self::assertEquals(
- 'CREATE INDEX fooindex ON footable (a, b)',
- $this->_platform->getCreateIndexSQL(
- new Index(
- 'fooindex',
- array('a', 'b'),
- false,
- false,
- array('with_nulls_not_distinct')
- ),
- 'footable'
- )
- );
- }
-}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php
deleted file mode 100644
index c66bb5177ab..00000000000
--- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php
+++ /dev/null
@@ -1,79 +0,0 @@
-_platform->getCreateIndexSQL(
- new Index(
- 'fooindex',
- array('a', 'b'),
- true,
- false,
- array('with_nulls_distinct')
- ),
- 'footable'
- )
- );
-
- // WITH NULLS DISTINCT clause not available on primary indexes.
- self::assertEquals(
- 'ALTER TABLE footable ADD PRIMARY KEY (a, b)',
- $this->_platform->getCreateIndexSQL(
- new Index(
- 'fooindex',
- array('a', 'b'),
- false,
- true,
- array('with_nulls_distinct')
- ),
- 'footable'
- )
- );
-
- // WITH NULLS DISTINCT clause not available on non-unique indexes.
- self::assertEquals(
- 'CREATE INDEX fooindex ON footable (a, b)',
- $this->_platform->getCreateIndexSQL(
- new Index(
- 'fooindex',
- array('a', 'b'),
- false,
- false,
- array('with_nulls_distinct')
- ),
- 'footable'
- )
- );
-
- parent::testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL();
- }
-
- public function testThrowsExceptionOnInvalidWithNullsNotDistinctIndexOptions()
- {
- $this->expectException('UnexpectedValueException');
-
- $this->_platform->getCreateIndexSQL(
- new Index(
- 'fooindex',
- array('a', 'b'),
- false,
- false,
- array('with_nulls_distinct', 'with_nulls_not_distinct')
- ),
- 'footable'
- );
- }
-}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
index 29af76826ae..40100af27ac 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
@@ -2,7 +2,6 @@
namespace Doctrine\Tests\DBAL\Platforms;
-use Doctrine\DBAL\Connection;
use Doctrine\DBAL\LockMode;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\SQLAnywherePlatform;
@@ -12,8 +11,10 @@
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Index;
+use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
+use Doctrine\DBAL\Schema\UniqueConstraint;
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\Type;
use function mt_rand;
@@ -374,12 +375,12 @@ public function testGeneratesUniqueConstraintDeclarationSQL()
'CONSTRAINT unique_constraint UNIQUE CLUSTERED (a, b)',
$this->_platform->getUniqueConstraintDeclarationSQL(
'unique_constraint',
- new Index(null, array('a', 'b'), true, false, array('clustered'))
+ new UniqueConstraint(null, array('a', 'b'), array('clustered'))
)
);
self::assertEquals(
- 'UNIQUE (a, b)',
- $this->_platform->getUniqueConstraintDeclarationSQL(null, new Index(null, array('a', 'b'), true, false))
+ 'CONSTRAINT UNIQUE (a, b)',
+ $this->_platform->getUniqueConstraintDeclarationSQL(null, new UniqueConstraint(null, array('a', 'b')))
);
}
@@ -387,7 +388,7 @@ public function testCannotGenerateUniqueConstraintDeclarationSQLWithEmptyColumns
{
$this->expectException('\InvalidArgumentException');
- $this->_platform->getUniqueConstraintDeclarationSQL('constr', new Index('constr', array(), true));
+ $this->_platform->getUniqueConstraintDeclarationSQL('constr', new UniqueConstraint('constr', array()));
}
public function testGeneratesForeignKeyConstraintsWithAdvancedPlatformOptionsSQL()
@@ -467,18 +468,121 @@ public function testCannotGenerateCustomConstraintWithCreateConstraintSQL()
public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL()
{
self::assertEquals(
- 'CREATE VIRTUAL UNIQUE CLUSTERED INDEX fooindex ON footable (a, b) FOR OLAP WORKLOAD',
+ 'CREATE UNIQUE INDEX fooindex ON footable (a, b) WITH NULLS DISTINCT',
$this->_platform->getCreateIndexSQL(
new Index(
'fooindex',
- array('a', 'b'),
+ ['a', 'b'],
true,
false,
- array('virtual', 'clustered', 'for_olap_workload')
+ ['with_nulls_distinct']
),
'footable'
)
);
+
+ // WITH NULLS DISTINCT clause not available on primary indexes.
+ self::assertEquals(
+ 'ALTER TABLE footable ADD PRIMARY KEY (a, b)',
+ $this->_platform->getCreateIndexSQL(
+ new Index(
+ 'fooindex',
+ ['a', 'b'],
+ false,
+ true,
+ ['with_nulls_distinct']
+ ),
+ 'footable'
+ )
+ );
+
+ // WITH NULLS DISTINCT clause not available on non-unique indexes.
+ self::assertEquals(
+ 'CREATE INDEX fooindex ON footable (a, b)',
+ $this->_platform->getCreateIndexSQL(
+ new Index(
+ 'fooindex',
+ ['a', 'b'],
+ false,
+ false,
+ ['with_nulls_distinct']
+ ),
+ 'footable'
+ )
+ );
+
+ self::assertEquals(
+ 'CREATE VIRTUAL UNIQUE CLUSTERED INDEX fooindex ON footable (a, b) WITH NULLS NOT DISTINCT FOR OLAP WORKLOAD',
+ $this->_platform->getCreateIndexSQL(
+ new Index(
+ 'fooindex',
+ ['a', 'b'],
+ true,
+ false,
+ ['virtual', 'clustered', 'with_nulls_not_distinct', 'for_olap_workload']
+ ),
+ 'footable'
+ )
+ );
+ self::assertEquals(
+ 'CREATE VIRTUAL CLUSTERED INDEX fooindex ON footable (a, b) FOR OLAP WORKLOAD',
+ $this->_platform->getCreateIndexSQL(
+ new Index(
+ 'fooindex',
+ ['a', 'b'],
+ false,
+ false,
+ ['virtual', 'clustered', 'with_nulls_not_distinct', 'for_olap_workload']
+ ),
+ 'footable'
+ )
+ );
+
+ // WITH NULLS NOT DISTINCT clause not available on primary indexes.
+ self::assertEquals(
+ 'ALTER TABLE footable ADD PRIMARY KEY (a, b)',
+ $this->_platform->getCreateIndexSQL(
+ new Index(
+ 'fooindex',
+ ['a', 'b'],
+ false,
+ true,
+ ['with_nulls_not_distinct']
+ ),
+ 'footable'
+ )
+ );
+
+ // WITH NULLS NOT DISTINCT clause not available on non-unique indexes.
+ self::assertEquals(
+ 'CREATE INDEX fooindex ON footable (a, b)',
+ $this->_platform->getCreateIndexSQL(
+ new Index(
+ 'fooindex',
+ ['a', 'b'],
+ false,
+ false,
+ ['with_nulls_not_distinct']
+ ),
+ 'footable'
+ )
+ );
+ }
+
+ public function testThrowsExceptionOnInvalidWithNullsNotDistinctIndexOptions()
+ {
+ $this->expectException('UnexpectedValueException');
+
+ $this->_platform->getCreateIndexSQL(
+ new Index(
+ 'fooindex',
+ ['a', 'b'],
+ false,
+ false,
+ ['with_nulls_distinct', 'with_nulls_not_distinct']
+ ),
+ 'footable'
+ );
}
public function testDoesNotSupportIndexDeclarationInCreateAlterTableStatements()
@@ -588,19 +692,28 @@ public function testGeneratesSQLSnippets()
);
}
- public function testDoesNotSupportRegexp()
+ public function testHasCorrectDateTimeTzFormatString()
{
- $this->expectException('\Doctrine\DBAL\DBALException');
+ self::assertEquals('Y-m-d H:i:s.uP', $this->_platform->getDateTimeTzFormatString());
+ }
- $this->_platform->getRegexpExpression();
+ public function testGeneratesDateTimeTzColumnTypeDeclarationSQL()
+ {
+ self::assertEquals(
+ 'TIMESTAMP WITH TIME ZONE',
+ $this->_platform->getDateTimeTzTypeDeclarationSQL([
+ 'length' => 10,
+ 'fixed' => true,
+ 'unsigned' => true,
+ 'autoincrement' => true,
+ ])
+ );
}
- public function testHasCorrectDateTimeTzFormatString()
+ public function testInitializesDateTimeTzTypeMapping()
{
- // Date time type with timezone is not supported before version 12.
- // For versions before we have to ensure that the date time with timezone format
- // equals the normal date time format so that it corresponds to the declaration SQL equality (datetimetz -> datetime).
- self::assertEquals($this->_platform->getDateTimeFormatString(), $this->_platform->getDateTimeTzFormatString());
+ self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('timestamp with time zone'));
+ self::assertEquals('datetime', $this->_platform->getDoctrineTypeMapping('timestamp with time zone'));
}
public function testHasCorrectDefaultTransactionIsolationLevel()
@@ -751,7 +864,41 @@ public function testSupportsGettingAffectedRows()
public function testDoesNotSupportSequences()
{
- self::assertFalse($this->_platform->supportsSequences());
+ self::markTestSkipped('This version of the platform now supports sequences.');
+ }
+
+ public function testSupportsSequences()
+ {
+ self::assertTrue($this->_platform->supportsSequences());
+ }
+
+ public function testGeneratesSequenceSqlCommands()
+ {
+ $sequence = new Sequence('myseq', 20, 1);
+ self::assertEquals(
+ 'CREATE SEQUENCE myseq INCREMENT BY 20 START WITH 1 MINVALUE 1',
+ $this->_platform->getCreateSequenceSQL($sequence)
+ );
+ self::assertEquals(
+ 'ALTER SEQUENCE myseq INCREMENT BY 20',
+ $this->_platform->getAlterSequenceSQL($sequence)
+ );
+ self::assertEquals(
+ 'DROP SEQUENCE myseq',
+ $this->_platform->getDropSequenceSQL('myseq')
+ );
+ self::assertEquals(
+ 'DROP SEQUENCE myseq',
+ $this->_platform->getDropSequenceSQL($sequence)
+ );
+ self::assertEquals(
+ 'SELECT myseq.NEXTVAL',
+ $this->_platform->getSequenceNextValSQL('myseq')
+ );
+ self::assertEquals(
+ 'SELECT sequence_name, increment_by, start_with, min_value FROM SYS.SYSSEQUENCE',
+ $this->_platform->getListSequencesSQL(null)
+ );
}
public function testDoesNotSupportInlineColumnComments()
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2008PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2008PlatformTest.php
deleted file mode 100644
index 3670c4a80a6..00000000000
--- a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2008PlatformTest.php
+++ /dev/null
@@ -1,18 +0,0 @@
-_platform->getDateTimeTzTypeDeclarationSQL([]));
- }
-}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php
index f8b42f61819..366ad106e43 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php
@@ -67,4 +67,9 @@ public function getModifyLimitQueries()
],
];
}
+
+ public function testGeneratesTypeDeclarationForDateTimeTz()
+ {
+ self::assertEquals('DATETIMEOFFSET(6)', $this->_platform->getDateTimeTzTypeDeclarationSQL([]));
+ }
}
diff --git a/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php b/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
index 8aa1882cc0f..853a3646b84 100644
--- a/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
+++ b/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
@@ -410,6 +410,16 @@ public function testUpdateWithoutAlias()
self::assertEquals('UPDATE users SET foo = ?, bar = ?', (string) $qb);
}
+ public function testUpdateWithMatchingAlias()
+ {
+ $qb = new QueryBuilder($this->conn);
+ $qb->update('users', 'users')
+ ->set('foo', '?')
+ ->set('bar', '?');
+
+ self::assertEquals('UPDATE users SET foo = ?, bar = ?', (string) $qb);
+ }
+
public function testUpdateWhere()
{
$qb = new QueryBuilder($this->conn);
@@ -447,6 +457,15 @@ public function testDeleteWithoutAlias()
self::assertEquals('DELETE FROM users', (string) $qb);
}
+ public function testDeleteWithMatchingAlias()
+ {
+ $qb = new QueryBuilder($this->conn);
+ $qb->delete('users', 'users');
+
+ self::assertEquals(QueryBuilder::DELETE, $qb->getType());
+ self::assertEquals('DELETE FROM users', (string) $qb);
+ }
+
public function testDeleteWhere()
{
$qb = new QueryBuilder($this->conn);
@@ -776,6 +795,16 @@ public function testSimpleSelectWithoutTableAlias()
self::assertEquals('SELECT id FROM users', (string) $qb);
}
+ public function testSimpleSelectWithMatchingTableAlias()
+ {
+ $qb = new QueryBuilder($this->conn);
+
+ $qb->select('id')
+ ->from('users', 'users');
+
+ self::assertEquals('SELECT id FROM users', (string) $qb);
+ }
+
public function testSelectWithSimpleWhereWithoutTableAlias()
{
$qb = new QueryBuilder($this->conn);
diff --git a/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php b/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php
index c357988bf6a..4fdf079283d 100644
--- a/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php
+++ b/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php
@@ -449,8 +449,10 @@ public function dataQueryWithMissingParameters()
/**
* @dataProvider dataQueryWithMissingParameters
+ * @param mixed[] $params
+ * @param mixed[] $types
*/
- public function testExceptionIsThrownForMissingParam($query, $params, $types = array())
+ public function testExceptionIsThrownForMissingParam(string $query, array $params = [], array $types = []) : void
{
$this->expectException(
'Doctrine\DBAL\SQLParserUtilsException',
diff --git a/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php b/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
index 40250020023..b5bd6abf9b0 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\Tests\DBAL\Schema;
@@ -1251,6 +1234,7 @@ public function testForeignKeyRemovalWithRenamedLocalColumn()
'id_table1' => new Column('id_table1', Type::getType('integer'))
),
array(),
+ array(),
array(
new ForeignKeyConstraint(array('id_table1'), 'table1', array('id'), 'fk_table2_table1')
))
@@ -1262,6 +1246,7 @@ public function testForeignKeyRemovalWithRenamedLocalColumn()
'id_table3' => new Column('id_table3', Type::getType('integer'))
),
array(),
+ array(),
array(
new ForeignKeyConstraint(array('id_table3'), 'table3', array('id'), 'fk_table2_table3')
)),
diff --git a/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php b/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php
index 0071d217280..f1f8902a52d 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\Tests\DBAL\Schema\Synchronizer;
diff --git a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php b/tests/Doctrine/Tests/DBAL/Schema/TableTest.php
index 9c4dee07eed..eddd2b83037 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/TableTest.php
@@ -196,7 +196,7 @@ public function testConstraints()
{
$constraint = new ForeignKeyConstraint(array(), "foo", array());
- $tableA = new Table("foo", array(), array(), array($constraint));
+ $tableA = new Table("foo", array(), array(), array(), array($constraint));
$constraints = $tableA->getForeignKeys();
self::assertCount(1, $constraints);
@@ -205,7 +205,7 @@ public function testConstraints()
public function testOptions()
{
- $table = new Table("foo", array(), array(), array(), false, array("foo" => "bar"));
+ $table = new Table("foo", array(), array(), array(), array(), array("foo" => "bar"));
self::assertTrue($table->hasOption("foo"));
self::assertEquals("bar", $table->getOption("foo"));
diff --git a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php
index 22cbcd6c066..4b6bc232406 100644
--- a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\Tests\DBAL\Sharding;
diff --git a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php
index b39efcf0b45..c965c9bd39f 100644
--- a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php
@@ -1,21 +1,5 @@
.
- */
+
namespace Doctrine\Tests\DBAL\Sharding;
use Doctrine\DBAL\Sharding\PoolingShardManager;
diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php
index 99be4eff108..425414f2041 100644
--- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php
+++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\Tests\DBAL\Sharding\SQLAzure;
diff --git a/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php b/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php
index cf4da5b317d..90e169b1b01 100644
--- a/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php
+++ b/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\Tests\DBAL\Sharding\ShardChoser;
diff --git a/tests/Doctrine/Tests/DBAL/StatementTest.php b/tests/Doctrine/Tests/DBAL/StatementTest.php
index fa22536f2d4..ff19217917d 100644
--- a/tests/Doctrine/Tests/DBAL/StatementTest.php
+++ b/tests/Doctrine/Tests/DBAL/StatementTest.php
@@ -2,9 +2,15 @@
namespace Doctrine\Tests\DBAL;
+use Doctrine\DBAL\Configuration;
+use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Driver;
+use Doctrine\DBAL\Driver\Connection as DriverConnection;
+use Doctrine\DBAL\Driver\Statement as DriverStatement;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Statement;
use Doctrine\DBAL\Logging\SQLLogger;
+use Doctrine\Tests\DBAL\Mocks\MockPlatform;
class StatementTest extends \Doctrine\Tests\DbalTestCase
{
@@ -23,34 +29,29 @@ class StatementTest extends \Doctrine\Tests\DbalTestCase
/**
* @var \PDOStatement
*/
- private $pdoStatement;
+ private $driverStatement;
protected function setUp()
{
- $this->pdoStatement = $this->getMockBuilder('\PDOStatement')
- ->setMethods(array('execute', 'bindParam', 'bindValue'))
- ->getMock();
- $platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform();
- $driverConnection = $this->createMock('\Doctrine\DBAL\Driver\Connection');
- $driverConnection->expects($this->any())
- ->method('prepare')
- ->will($this->returnValue($this->pdoStatement));
-
- $driver = $this->createMock('\Doctrine\DBAL\Driver');
- $constructorArgs = array(
- array(
- 'platform' => $platform
- ),
- $driver
- );
- $this->conn = $this->getMockBuilder('\Doctrine\DBAL\Connection')
- ->setConstructorArgs($constructorArgs)
+ $this->driverStatement = $this->createMock(DriverStatement::class);
+
+ $driverConnection = $this->createConfiguredMock(DriverConnection::class, [
+ 'prepare' => $this->driverStatement,
+ ]);
+
+ $driver = $this->createMock(Driver::class);
+
+ $this->conn = $this->getMockBuilder(Connection::class)
+ ->setConstructorArgs([
+ ['platform' => new MockPlatform()],
+ $driver,
+ ])
->getMock();
$this->conn->expects($this->atLeastOnce())
->method('getWrappedConnection')
->will($this->returnValue($driverConnection));
- $this->configuration = $this->createMock('\Doctrine\DBAL\Configuration');
+ $this->configuration = $this->createMock(Configuration::class);
$this->conn->expects($this->any())
->method('getConfiguration')
->will($this->returnValue($this->configuration));
@@ -58,7 +59,6 @@ protected function setUp()
$this->conn->expects($this->any())
->method('getDriver')
->will($this->returnValue($driver));
-
}
public function testExecuteCallsLoggerStartQueryWithParametersWhenValuesBound()
@@ -149,7 +149,7 @@ public function testExecuteCallsLoggerStopQueryOnException()
$logger->expects($this->once())
->method('stopQuery');
- $this->pdoStatement->expects($this->once())
+ $this->driverStatement->expects($this->once())
->method('execute')
->will($this->throwException(new \Exception("Mock test exception")));
diff --git a/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php b/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php
deleted file mode 100644
index 760dbff40cf..00000000000
--- a/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php
+++ /dev/null
@@ -1,23 +0,0 @@
-.
- */
namespace Doctrine\Tests\Mocks;