diff --git a/.travis.yml b/.travis.yml index e46f9220981..a5308308b80 100644 --- a/.travis.yml +++ b/.travis.yml @@ -103,21 +103,6 @@ jobs: addons: mariadb: 10.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.2 env: DB=pgsql POSTGRESQL_VERSION=9.3 diff --git a/UPGRADE.md b/UPGRADE.md index 39d2b4e4b0a..f44f8e47555 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,59 @@ # 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. diff --git a/docs/en/reference/configuration.rst b/docs/en/reference/configuration.rst index 424023648ae..bc130cc05a8 100644 --- a/docs/en/reference/configuration.rst +++ b/docs/en/reference/configuration.rst @@ -230,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``. @@ -311,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/platforms.rst b/docs/en/reference/platforms.rst index 19917bf4f18..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 ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/en/reference/types.rst b/docs/en/reference/types.rst index dfc178462f0..a7801311c97 100644 --- a/docs/en/reference/types.rst +++ b/docs/en/reference/types.rst @@ -671,9 +671,7 @@ Please also notice the mapping specific footnotes for additional information. | | +--------------------------+ | | | | | **SQLite** | | | | | +--------------------------+---------+ | -| | | **SQL Server** | >= 2008 | | -| | | +---------+----------------------------------------------------------+ -| | | | < 2008 | ``DATETIME`` [15]_ | +| | | **SQL Server** | "all" | | +-------------------+---------------+--------------------------+---------+----------------------------------------------------------+ | **datetime** | ``\DateTime`` | **MySQL** | *all* | ``DATETIME`` [13]_ | | | +--------------------------+---------+----------------------------------------------------------+ @@ -691,17 +689,13 @@ Please also notice the mapping specific footnotes for additional information. | | +--------------------------+ | | | | | **SQLite** | | | | | +--------------------------+---------+ | -| | | **SQL Server** | < 2008 | | -| | | +---------+----------------------------------------------------------+ -| | | | >= 2008 | ``DATETIMEOFFSET(6)`` | +| | | **SQL Server** | "all" | | | | +--------------------------+---------+----------------------------------------------------------+ | | | **PostgreSQL** | *all* | ``TIMESTAMP(0) WITH TIME ZONE`` | | | +--------------------------+ | | | | | **Oracle** | | | | | +--------------------------+---------+----------------------------------------------------------+ -| | | **SQL Anywhere** | < 12 | ``DATETIME`` [14]_ [15]_ | -| | | +---------+----------------------------------------------------------+ -| | | | >= 12 | ``TIMESTAMP WITH TIME ZONE`` | +| | | **SQL Anywhere** | "all" | ``TIMESTAMP WITH TIME ZONE`` | +-------------------+---------------+--------------------------+---------+----------------------------------------------------------+ | **time** | ``\DateTime`` | **MySQL** | *all* | ``TIME`` | | | +--------------------------+ | | @@ -713,9 +707,7 @@ Please also notice the mapping specific footnotes for additional information. | | +--------------------------+---------+----------------------------------------------------------+ | | | **Oracle** | *all* | ``DATE`` [15]_ | | | +--------------------------+---------+----------------------------------------------------------+ -| | | **SQL Server** | < 2008 | ``DATETIME`` [15]_ | -| | | +---------+----------------------------------------------------------+ -| | | | >= 2008 | ``TIME(0)`` | +| | | **SQL Server** | "all" | ``TIME(0)`` | +-------------------+---------------+--------------------------+---------+----------------------------------------------------------+ | **array** [1]_ | ``array`` | **MySQL** | *all* | ``TINYTEXT`` [16]_ | +-------------------+ | | +----------------------------------------------------------+ @@ -743,9 +735,7 @@ Please also notice the mapping specific footnotes for additional information. | | | | +----------------------------------------------------------+ | | | | | ``LONGTEXT`` [19]_ | | | +--------------------------+---------+----------------------------------------------------------+ -| | | **PostgreSQL** | < 9.2 | ``TEXT`` [1]_ | -| | | +---------+----------------------------------------------------------+ -| | | | < 9.4 | ``JSON`` | +| | | **PostgreSQL** | < 9.4 | ``JSON`` | | | | +---------+----------------------------------------------------------+ | | | | >= 9.4 | ``JSON`` [20]_ | | | | | +----------------------------------------------------------+ diff --git a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php index 67b7c4cbf0d..f9fafb28928 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php @@ -6,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; @@ -101,10 +99,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 2dbc5030847..c83458e0037 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php @@ -5,9 +5,6 @@ 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; @@ -89,12 +86,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(); } @@ -115,7 +106,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 548ed4fc20a..db4be133664 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php @@ -4,8 +4,6 @@ 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; @@ -45,10 +43,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(); } @@ -69,7 +63,7 @@ public function getDatabase(\Doctrine\DBAL\Connection $conn) */ public function getDatabasePlatform() { - return new SQLServer2008Platform(); + return new SQLServerPlatform(); } /** diff --git a/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php b/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php deleted file mode 100644 index f082cf99334..00000000000 --- a/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @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/Platforms/DB2Platform.php b/lib/Doctrine/DBAL/Platforms/DB2Platform.php index bc054436aca..82b493888ac 100644 --- a/lib/Doctrine/DBAL/Platforms/DB2Platform.php +++ b/lib/Doctrine/DBAL/Platforms/DB2Platform.php @@ -43,21 +43,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/Keywords/DB2Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/DB2Keywords.php index 0dbceb3d537..cb055df6689 100644 --- a/lib/Doctrine/DBAL/Platforms/Keywords/DB2Keywords.php +++ b/lib/Doctrine/DBAL/Platforms/Keywords/DB2Keywords.php @@ -31,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', @@ -116,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', @@ -183,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', @@ -250,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', @@ -317,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/MsSQLKeywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php deleted file mode 100644 index 239d047de77..00000000000 --- a/lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php +++ /dev/null @@ -1,26 +0,0 @@ - - * @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/OracleKeywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/OracleKeywords.php index cc1140a20d2..c0d5d1ed226 100644 --- a/lib/Doctrine/DBAL/Platforms/Keywords/OracleKeywords.php +++ b/lib/Doctrine/DBAL/Platforms/Keywords/OracleKeywords.php @@ -27,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 3fe676e0bb4..00000000000 --- a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL91Keywords.php +++ /dev/null @@ -1,131 +0,0 @@ - - * @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 63dde1c1107..00000000000 --- a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL92Keywords.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @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 16cfa65c863..464dd5d7973 100644 --- a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL94Keywords.php +++ b/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL94Keywords.php @@ -9,7 +9,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 146e3a1ae10..7d0ba4e7584 100644 --- a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQLKeywords.php +++ b/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQLKeywords.php @@ -3,7 +3,7 @@ namespace Doctrine\DBAL\Platforms\Keywords; /** - * PostgreSQL Keywordlist. + * PostgreSQL 9.3 keywords list. * * @link www.doctrine-project.org * @since 2.0 @@ -31,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', @@ -57,6 +64,7 @@ protected function getKeywords() 'END', 'EXCEPT', 'FALSE', + 'FETCH', 'FOR', 'FOREIGN', 'FREEZE', @@ -81,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', @@ -110,9 +119,12 @@ protected function getKeywords() 'UNIQUE', 'USER', 'USING', + 'VARIADIC', 'VERBOSE', 'WHEN', - 'WHERE' + 'WHERE', + 'WINDOW', + 'WITH', ]; } } diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere11Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere11Keywords.php deleted file mode 100644 index 2c953b0b95d..00000000000 --- a/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere11Keywords.php +++ /dev/null @@ -1,38 +0,0 @@ - - */ -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 cd7f9d4d801..00000000000 --- a/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere12Keywords.php +++ /dev/null @@ -1,47 +0,0 @@ - - */ -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 c8cef87511e..00000000000 --- a/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere16Keywords.php +++ /dev/null @@ -1,39 +0,0 @@ - - */ -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 125f06d52d0..342177f4857 100644 --- a/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhereKeywords.php +++ b/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhereKeywords.php @@ -30,6 +30,7 @@ protected function getKeywords() 'ALTER', 'AND', 'ANY', + 'ARRAY', 'AS', 'ASC', 'ATTACH', @@ -70,6 +71,7 @@ protected function getKeywords() 'CURRENT_USER', 'CURSOR', 'DATE', + 'DATETIMEOFFSET', 'DBSPACE', 'DEALLOCATE', 'DEC', @@ -116,7 +118,6 @@ protected function getKeywords() 'IF', 'IN', 'INDEX', - 'INDEX_LPAREN', 'INNER', 'INOUT', 'INSENSITIVE', @@ -129,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', @@ -160,6 +163,8 @@ protected function getKeywords() 'OFF', 'ON', 'OPEN', + 'OPENSTRING', + 'OPENXML', 'OPTION', 'OPTIONS', 'OR', @@ -196,6 +201,8 @@ protected function getKeywords() 'RIGHT', 'ROLLBACK', 'ROLLUP', + 'ROW', + 'ROWTYPE', 'SAVE', 'SAVEPOINT', 'SCROLL', @@ -207,6 +214,7 @@ protected function getKeywords() 'SHARE', 'SMALLINT', 'SOME', + 'SPATIAL', 'SQLCODE', 'SQLSTATE', 'START', @@ -214,7 +222,6 @@ protected function getKeywords() 'SUBTRANS', 'SUBTRANSACTION', 'SYNCHRONIZE', - 'SYNTAX_ERROR', 'TABLE', 'TEMPORARY', 'THEN', @@ -224,6 +231,7 @@ protected function getKeywords() 'TO', 'TOP', 'TRAN', + 'TREAT', 'TRIGGER', 'TRUNCATE', 'TSEQUAL', @@ -232,6 +240,7 @@ protected function getKeywords() 'UNIQUE', 'UNIQUEIDENTIFIER', 'UNKNOWN', + 'UNNEST', 'UNSIGNED', 'UPDATE', 'UPDATING', @@ -243,6 +252,7 @@ protected function getKeywords() 'VARBIT', 'VARCHAR', 'VARIABLE', + 'VARRAY', 'VARYING', 'VIEW', 'WAIT', @@ -252,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 efc4eb24298..00000000000 --- a/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2005Keywords.php +++ /dev/null @@ -1,39 +0,0 @@ - - */ -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 342a80a2943..00000000000 --- a/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2008Keywords.php +++ /dev/null @@ -1,34 +0,0 @@ - - */ -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 b48048ef891..a4a598c147d 100644 --- a/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php +++ b/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php @@ -10,7 +10,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 d7287fbf991..5c5d6a924b5 100644 --- a/lib/Doctrine/DBAL/Platforms/Keywords/SQLServerKeywords.php +++ b/lib/Doctrine/DBAL/Platforms/Keywords/SQLServerKeywords.php @@ -126,6 +126,7 @@ protected function getKeywords() 'LIKE', 'LINENO', 'LOAD', + 'MERGE', 'NATIONAL', 'NOCHECK ', 'NONCLUSTERED', diff --git a/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php b/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php index 083c874263d..fdae0d2bed0 100644 --- a/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php @@ -998,36 +998,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 6040d704e5b..439acbd56b1 100644 --- a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php @@ -1101,29 +1101,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 18266c26677..00000000000 --- a/lib/Doctrine/DBAL/Platforms/PostgreSQL91Platform.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @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 f9deedd418d..00000000000 --- a/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @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 d0bc3fd8183..4cf1c1d31ce 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSQL94Platform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSQL94Platform.php @@ -11,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 bd0d3473c9d..61706eb7bfa 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php @@ -15,7 +15,7 @@ use Doctrine\DBAL\Types\Type; /** - * PostgreSqlPlatform. + * Provides the behavior, features and SQL dialect of the PostgreSQL 9.4+ database platform. * * @since 2.0 * @author Roman Borschel @@ -372,6 +372,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, @@ -434,7 +435,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; } /** @@ -938,6 +939,10 @@ public function getBigIntTypeDeclarationSQL(array $field) */ public function getSmallIntTypeDeclarationSQL(array $field) { + if (! empty($field['autoincrement'])) { + return 'SMALLSERIAL'; + } + return 'SMALLINT'; } @@ -1085,45 +1090,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', ]; } @@ -1151,6 +1157,14 @@ public function getBinaryDefaultLength() return 0; } + /** + * {@inheritdoc} + */ + public function hasNativeJsonType() + { + return true; + } + /** * {@inheritDoc} */ @@ -1189,6 +1203,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 875841a18d5..00000000000 --- a/lib/Doctrine/DBAL/Platforms/SQLAnywhere11Platform.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @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 bf8e232bfe1..00000000000 --- a/lib/Doctrine/DBAL/Platforms/SQLAnywhere12Platform.php +++ /dev/null @@ -1,118 +0,0 @@ - - * @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 8851474bfbd..00000000000 --- a/lib/Doctrine/DBAL/Platforms/SQLAnywhere16Platform.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @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 9afaf850390..f56d732d4f4 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php @@ -2,6 +2,7 @@ namespace Doctrine\DBAL\Platforms; +use Doctrine\Common\Proxy\Exception\UnexpectedValueException; use Doctrine\DBAL\DBALException; use Doctrine\DBAL\LockMode; use Doctrine\DBAL\Schema\Column; @@ -10,13 +11,14 @@ 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; /** * 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 @@ -500,7 +502,7 @@ public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration) */ public function getDateTimeTzFormatString() { - return $this->getDateTimeFormatString(); + return 'Y-m-d H:i:s.uP'; } /** @@ -960,6 +962,14 @@ public function getMd5Expression($column) return "HASH(" . $column . ", 'MD5')"; } + /** + * {@inheritdoc} + */ + public function getRegexpExpression() + { + return 'REGEXP'; + } + /** * {@inheritdoc} */ @@ -1123,6 +1133,70 @@ public function getTruncateTableSQL($tableName, $cascade = false) return 'TRUNCATE TABLE ' . $tableIdentifier->getQuotedName($this); } + /** + * {@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 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} + */ + public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration) + { + return 'TIMESTAMP WITH TIME ZONE'; + } + /** * {@inheritdoc} */ @@ -1286,12 +1360,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; } @@ -1412,44 +1501,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 d04a530c80e..0e8a2188a90 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLAzurePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLAzurePlatform.php @@ -11,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 1026a934f00..00000000000 --- a/lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php +++ /dev/null @@ -1,46 +0,0 @@ -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 3cf0b1b4d8d..4a9fc05fa93 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php @@ -12,7 +12,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 7c5f06968de..056782fe5f5 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php @@ -1101,6 +1101,14 @@ public function getGuidTypeDeclarationSQL(array $field) return 'UNIQUEIDENTIFIER'; } + /** + * {@inheritDoc} + */ + public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration) + { + return 'DATETIMEOFFSET(6)'; + } + /** * {@inheritDoc} */ @@ -1146,7 +1154,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)'; } /** @@ -1154,7 +1164,7 @@ public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration) */ public function getDateTypeDeclarationSQL(array $fieldDeclaration) { - return 'DATETIME'; + return 'DATE'; } /** @@ -1162,7 +1172,7 @@ public function getDateTypeDeclarationSQL(array $fieldDeclaration) */ public function getTimeTypeDeclarationSQL(array $fieldDeclaration) { - return 'DATETIME'; + return 'TIME(0)'; } /** @@ -1295,7 +1305,7 @@ private function isOrderByInTopNSubquery($query, $currentPosition) */ public function supportsLimitOffset() { - return false; + return true; } /** @@ -1337,7 +1347,7 @@ public function getTemporaryTableName($tableName) */ public function getDateTimeFormatString() { - return 'Y-m-d H:i:s.000'; + return 'Y-m-d H:i:s.u'; } /** @@ -1345,7 +1355,7 @@ public function getDateTimeFormatString() */ public function getDateFormatString() { - return 'Y-m-d H:i:s.000'; + return 'Y-m-d'; } /** @@ -1353,7 +1363,7 @@ public function getDateFormatString() */ public function getTimeFormatString() { - return 'Y-m-d H:i:s.000'; + return 'H:i:s'; } /** @@ -1361,7 +1371,7 @@ public function getTimeFormatString() */ public function getDateTimeTzFormatString() { - return $this->getDateTimeFormatString(); + return 'Y-m-d H:i:s.u P'; } /** @@ -1378,31 +1388,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', ]; } @@ -1563,6 +1577,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 6faad5df51e..82caebf139c 100644 --- a/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php @@ -580,38 +580,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', ]; } diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php index 1a778fea4e0..ffe4beaf00c 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php @@ -2,34 +2,41 @@ 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; use Symfony\Component\Console\Output\OutputInterface; +use function array_keys; 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, ]; /** @@ -77,17 +84,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 ); @@ -103,22 +106,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/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/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/Platforms/PostgreSQL91PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL91PlatformTest.php deleted file mode 100644 index ed09f26c92e..00000000000 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL91PlatformTest.php +++ /dev/null @@ -1,21 +0,0 @@ -_platform->getColumnCollationDeclarationSQL('en_US.UTF-8') - ); - } -} 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 0546017d956..28473a6bbac 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,6 +11,7 @@ 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; @@ -465,18 +465,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() @@ -586,19 +689,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() @@ -749,7 +861,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 c3f9b6f4023..e9667385c4e 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php @@ -57,4 +57,9 @@ public function getModifyLimitQueries() array('SELECT id_0, MIN(sclr_2) AS dctrn_minrownum FROM (SELECT c0_.id AS id_0, c0_.title AS title_1, ROW_NUMBER() OVER(ORDER BY c0_.title ASC) AS sclr_2 FROM TestTable c0_) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC', 30, null, 'WITH dctrn_cte AS (SELECT TOP 30 id_0, MIN(sclr_2) AS dctrn_minrownum FROM (SELECT c0_.id AS id_0, c0_.title AS title_1, ROW_NUMBER() OVER(ORDER BY c0_.title ASC) AS sclr_2 FROM TestTable c0_) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC) SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT 0)) AS doctrine_rownum FROM dctrn_cte) AS doctrine_tbl WHERE doctrine_rownum BETWEEN 1 AND 30 ORDER BY doctrine_rownum ASC'), ); } + + public function testGeneratesTypeDeclarationForDateTimeTz() + { + self::assertEquals('DATETIMEOFFSET(6)', $this->_platform->getDateTimeTzTypeDeclarationSQL([])); + } }