diff --git a/UPGRADE.md b/UPGRADE.md index 3381b183411..d4d939c21b1 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,20 @@ # Upgrade to 3.0 (DEVELOP) +## 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. diff --git a/docs/en/reference/configuration.rst b/docs/en/reference/configuration.rst index 9a2235bc5c4..bc130cc05a8 100644 --- a/docs/en/reference/configuration.rst +++ b/docs/en/reference/configuration.rst @@ -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/types.rst b/docs/en/reference/types.rst index b43da04ab90..a7801311c97 100644 --- a/docs/en/reference/types.rst +++ b/docs/en/reference/types.rst @@ -695,9 +695,7 @@ Please also notice the mapping specific footnotes for additional information. | | +--------------------------+ | | | | | **Oracle** | | | | | +--------------------------+---------+----------------------------------------------------------+ -| | | **SQL Anywhere** | < 12 | ``DATETIME`` [14]_ [15]_ | -| | | +---------+----------------------------------------------------------+ -| | | | >= 12 | ``TIMESTAMP WITH TIME ZONE`` | +| | | **SQL Anywhere** | "all" | ``TIMESTAMP WITH TIME ZONE`` | +-------------------+---------------+--------------------------+---------+----------------------------------------------------------+ | **time** | ``\DateTime`` | **MySQL** | *all* | ``TIME`` | | | +--------------------------+ | | 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/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/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..08ff0997c41 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; } @@ -1445,6 +1534,7 @@ protected function initializeDoctrineTypeMappings() 'smalldatetime' => 'datetime', 'time' => 'time', 'timestamp' => 'datetime', + 'timestamp with time zone' => 'datetime', 'binary' => 'binary', 'image' => 'blob', 'long binary' => 'blob', diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php index 29964d1a492..9591737d7c7 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php @@ -10,9 +10,6 @@ use Doctrine\DBAL\Platforms\Keywords\PostgreSQL94Keywords; use Doctrine\DBAL\Platforms\Keywords\PostgreSQLKeywords; use Doctrine\DBAL\Platforms\Keywords\ReservedKeywordsValidator; -use Doctrine\DBAL\Platforms\Keywords\SQLAnywhere11Keywords; -use Doctrine\DBAL\Platforms\Keywords\SQLAnywhere12Keywords; -use Doctrine\DBAL\Platforms\Keywords\SQLAnywhere16Keywords; use Doctrine\DBAL\Platforms\Keywords\SQLAnywhereKeywords; use Doctrine\DBAL\Platforms\Keywords\SQLiteKeywords; use Doctrine\DBAL\Platforms\Keywords\SQLServer2012Keywords; @@ -40,9 +37,6 @@ class ReservedWordsCommand extends Command 'oracle' => OracleKeywords::class, 'db2' => DB2Keywords::class, 'sqlanywhere' => SQLAnywhereKeywords::class, - 'sqlanywhere11' => SQLAnywhere11Keywords::class, - 'sqlanywhere12' => SQLAnywhere12Keywords::class, - 'sqlanywhere16' => SQLAnywhere16Keywords::class, ]; /** @@ -97,9 +91,6 @@ protected function configure() * sqlserver * sqlserver2012 * sqlanywhere - * sqlanywhere11 - * sqlanywhere12 - * sqlanywhere16 * db2 (Not checked by default) EOT ); 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/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()