Unverified Commit b1ad5280 authored by Michael Moravec's avatar Michael Moravec Committed by Sergei Morozov

Drop support for SQL Server <2008

parent fe9200a4
# Upgrade to 3.0
## 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.
......
......@@ -50,9 +50,7 @@ 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
......
......@@ -677,9 +677,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]_ |
| | +--------------------------+---------+----------------------------------------------------------+
......@@ -697,9 +695,7 @@ 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`` |
| | +--------------------------+ | |
......@@ -719,9 +715,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]_ |
+-------------------+ | | +----------------------------------------------------------+
......
......@@ -5,8 +5,6 @@ namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\Connection;
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;
......@@ -44,10 +42,6 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr
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();
}
......@@ -68,7 +62,7 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr
*/
public function getDatabasePlatform()
{
return new SQLServer2008Platform();
return new SQLServerPlatform();
}
/**
......
<?php
namespace Doctrine\DBAL\Platforms\Keywords;
use function array_diff;
use function array_merge;
/**
* Microsoft SQL Server 2005 reserved keyword dictionary.
*
* @link www.doctrine-project.com
*/
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',
]);
}
}
<?php
namespace Doctrine\DBAL\Platforms\Keywords;
use function array_merge;
/**
* Microsoft SQL Server 2008 reserved keyword dictionary.
*
* @link www.doctrine-project.com
*/
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']);
}
}
......@@ -9,7 +9,7 @@ use function array_merge;
*
* @link www.doctrine-project.com
*/
class SQLServer2012Keywords extends SQLServer2008Keywords
class SQLServer2012Keywords extends SQLServerKeywords
{
/**
* {@inheritdoc}
......
......@@ -121,6 +121,7 @@ class SQLServerKeywords extends KeywordList
'LIKE',
'LINENO',
'LOAD',
'MERGE',
'NATIONAL',
'NOCHECK ',
'NONCLUSTERED',
......
......@@ -11,7 +11,7 @@ use Doctrine\DBAL\Schema\Table;
*
* - Create tables with the FEDERATED ON syntax.
*/
class SQLAzurePlatform extends SQLServer2008Platform
class SQLAzurePlatform extends SQLServerPlatform
{
/**
* {@inheritDoc}
......
<?php
namespace Doctrine\DBAL\Platforms;
/**
* Platform to ensure compatibility of Doctrine with Microsoft SQL Server 2005 version and
* higher.
*
* Differences to SQL Server 2008 are:
*
* - DATETIME2 datatype does not exist, only DATETIME which has a precision of
* 3. This is not supported by PHP DateTime, so we are emulating it by
* setting .000 manually.
* - Starting with SQLServer2005 VARCHAR(MAX), VARBINARY(MAX) and
* NVARCHAR(max) replace the old TEXT, NTEXT and IMAGE types. See
* {@link http://www.sql-server-helper.com/faq/sql-server-2005-varchar-max-p01.aspx}
* for more information.
*/
class SQLServer2005Platform extends SQLServerPlatform
{
/**
* {@inheritDoc}
*/
public function supportsLimitOffset()
{
return true;
}
/**
* {@inheritDoc}
*/
public function getClobTypeDeclarationSQL(array $field)
{
return 'VARCHAR(MAX)';
}
/**
* {@inheritdoc}
*
* Returns Microsoft SQL Server 2005 specific keywords class
*/
protected function getReservedKeywordsClass()
{
return Keywords\SQLServer2005Keywords::class;
}
}
<?php
namespace Doctrine\DBAL\Platforms;
/**
* Platform to ensure compatibility of Doctrine with Microsoft SQL Server 2008 version.
*
* Differences to SQL Server 2005 and before are that a new DATETIME2 type was
* introduced that has a higher precision.
*/
class SQLServer2008Platform extends SQLServer2005Platform
{
/**
* {@inheritDoc}
*/
public function getListTablesSQL()
{
// "sysdiagrams" table must be ignored as it's internal SQL Server table for Database Diagrams
// Category 2 must be ignored as it is "MS SQL Server 'pseudo-system' object[s]" for replication
return "SELECT name, SCHEMA_NAME (uid) AS schema_name FROM sysobjects WHERE type = 'U' AND name != 'sysdiagrams' AND category != 2 ORDER BY name";
}
/**
* {@inheritDoc}
*/
public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
{
// 3 - microseconds precision length
// http://msdn.microsoft.com/en-us/library/ms187819.aspx
return 'DATETIME2(6)';
}
/**
* {@inheritDoc}
*/
public function getDateTypeDeclarationSQL(array $fieldDeclaration)
{
return 'DATE';
}
/**
* {@inheritDoc}
*/
public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
{
return 'TIME(0)';
}
/**
* {@inheritDoc}
*/
public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)
{
return 'DATETIMEOFFSET(6)';
}
/**
* {@inheritDoc}
*/
public function getDateTimeFormatString()
{
return 'Y-m-d H:i:s.u';
}
/**
* {@inheritDoc}
*/
public function getDateTimeTzFormatString()
{
return 'Y-m-d H:i:s.u P';
}
/**
* {@inheritDoc}
*/
public function getDateFormatString()
{
return 'Y-m-d';
}
/**
* {@inheritDoc}
*/
public function getTimeFormatString()
{
return 'H:i:s';
}
/**
* {@inheritDoc}
*
* Adding Datetime2 Type
*/
protected function initializeDoctrineTypeMappings()
{
parent::initializeDoctrineTypeMappings();
$this->doctrineTypeMapping['datetime2'] = 'datetime';
$this->doctrineTypeMapping['date'] = 'date';
$this->doctrineTypeMapping['time'] = 'time';
$this->doctrineTypeMapping['datetimeoffset'] = 'datetimetz';
}
/**
* {@inheritdoc}
*
* Returns Microsoft SQL Server 2008 specific keywords class
*/
protected function getReservedKeywordsClass()
{
return Keywords\SQLServer2008Keywords::class;
}
protected function getLikeWildcardCharacters() : string
{
return parent::getLikeWildcardCharacters() . '[]^';
}
}
......@@ -14,7 +14,7 @@ use function substr_count;
* Differences to SQL Server 2008 and before are that sequences are introduced,
* and support for the new OFFSET... FETCH syntax for result pagination has been added.
*/
class SQLServer2012Platform extends SQLServer2008Platform
class SQLServer2012Platform extends SQLServerPlatform
{
/**
* {@inheritdoc}
......
......@@ -874,7 +874,7 @@ SQL
{
// "sysdiagrams" table must be ignored as it's internal SQL Server table for Database Diagrams
// Category 2 must be ignored as it is "MS SQL Server 'pseudo-system' object[s]" for replication
return "SELECT name FROM sysobjects WHERE type = 'U' AND name != 'sysdiagrams' AND category != 2 ORDER BY name";
return "SELECT name, SCHEMA_NAME (uid) AS schema_name FROM sysobjects WHERE type = 'U' AND name != 'sysdiagrams' AND category != 2 ORDER BY name";
}
/**
......@@ -1162,6 +1162,14 @@ SQL
return 'UNIQUEIDENTIFIER';
}
/**
* {@inheritDoc}
*/
public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)
{
return 'DATETIMEOFFSET(6)';
}
/**
* {@inheritDoc}
*/
......@@ -1207,7 +1215,9 @@ SQL
*/
public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
{
return 'DATETIME';
// 3 - microseconds precision length
// http://msdn.microsoft.com/en-us/library/ms187819.aspx
return 'DATETIME2(6)';
}
/**
......@@ -1215,7 +1225,7 @@ SQL
*/
public function getDateTypeDeclarationSQL(array $fieldDeclaration)
{
return 'DATETIME';
return 'DATE';
}
/**
......@@ -1223,7 +1233,7 @@ SQL
*/
public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
{
return 'DATETIME';
return 'TIME(0)';
}
/**
......@@ -1369,7 +1379,7 @@ SQL
*/
public function supportsLimitOffset()
{
return false;
return true;
}
/**
......@@ -1413,7 +1423,7 @@ SQL
*/
public function getDateTimeFormatString()
{
return 'Y-m-d H:i:s.000';
return 'Y-m-d H:i:s.u';
}
/**
......@@ -1421,7 +1431,7 @@ SQL
*/
public function getDateFormatString()
{
return 'Y-m-d H:i:s.000';
return 'Y-m-d';
}
/**
......@@ -1429,7 +1439,7 @@ SQL
*/
public function getTimeFormatString()
{
return 'Y-m-d H:i:s.000';
return 'H:i:s';
}
/**
......@@ -1437,7 +1447,7 @@ SQL
*/
public function getDateTimeTzFormatString()
{
return $this->getDateTimeFormatString();
return 'Y-m-d H:i:s.u P';
}
/**
......@@ -1479,6 +1489,10 @@ SQL
'varbinary' => 'binary',
'image' => 'blob',
'uniqueidentifier' => 'guid',
'datetime2' => 'datetime',
'date' => 'date',
'time' => 'time',
'datetimeoffset' => 'datetimetz',
];
}
......@@ -1639,6 +1653,14 @@ SQL
return $name . ' ' . $columnDef;
}
/**
* {@inheritdoc}
*/
protected function getLikeWildcardCharacters() : string
{
return parent::getLikeWildcardCharacters() . '[]^';
}
/**
* Returns a unique default constraint name for a table and column.
*
......
......@@ -17,8 +17,6 @@ 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\SQLServer2005Keywords;
use Doctrine\DBAL\Platforms\Keywords\SQLServer2008Keywords;
use Doctrine\DBAL\Platforms\Keywords\SQLServer2012Keywords;
use Doctrine\DBAL\Platforms\Keywords\SQLServerKeywords;
use Doctrine\DBAL\Schema\Schema;
......@@ -39,8 +37,6 @@ class ReservedWordsCommand extends Command
'mysql57' => MySQL57Keywords::class,
'mysql80' => MySQL80Keywords::class,
'sqlserver' => SQLServerKeywords::class,
'sqlserver2005' => SQLServer2005Keywords::class,
'sqlserver2008' => SQLServer2008Keywords::class,
'sqlserver2012' => SQLServer2012Keywords::class,
'sqlite' => SQLiteKeywords::class,
'pgsql' => PostgreSQLKeywords::class,
......@@ -107,8 +103,6 @@ The following keyword lists are currently shipped with Doctrine:
* sqlite
* oracle
* sqlserver
* sqlserver2005
* sqlserver2008
* sqlserver2012
* sqlanywhere
* sqlanywhere11
......
......@@ -4,8 +4,6 @@ namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\AbstractSQLServerDriver;
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;
......@@ -19,7 +17,7 @@ class AbstractSQLServerDriverTest extends AbstractDriverTest
protected function createPlatform()
{
return new SQLServer2008Platform();
return new SQLServerPlatform();
}
protected function createSchemaManager(Connection $connection)
......@@ -30,27 +28,19 @@ class AbstractSQLServerDriverTest extends AbstractDriverTest
protected function getDatabasePlatformsForVersions()
{
return [
['9', SQLServerPlatform::class],
['9.00', SQLServerPlatform::class],
['9.00.0', SQLServerPlatform::class],
['9.00.1398', SQLServerPlatform::class],
['9.00.1398.99', SQLServerPlatform::class],
['9.00.1399', SQLServer2005Platform::class],
['9.00.1399.0', SQLServer2005Platform::class],
['9.00.1399.99', SQLServer2005Platform::class],
['9.00.1400', SQLServer2005Platform::class],
['9.10', SQLServer2005Platform::class],
['9.10.9999', SQLServer2005Platform::class],
['10.00.1599', SQLServer2005Platform::class],
['10.00.1599.99', SQLServer2005Platform::class],
['10.00.1600', SQLServer2008Platform::class],
['10.00.1600.0', SQLServer2008Platform::class],
['10.00.1600.99', SQLServer2008Platform::class],
['10.00.1601', SQLServer2008Platform::class],
['10.10', SQLServer2008Platform::class],
['10.10.9999', SQLServer2008Platform::class],
['11.00.2099', SQLServer2008Platform::class],
['11.00.2099.99', SQLServer2008Platform::class],
['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],
......
<?php
namespace Doctrine\Tests\DBAL\Platforms;
use Doctrine\DBAL\Platforms\SQLServer2008Platform;
class SQLServer2008PlatformTest extends AbstractSQLServerPlatformTestCase
{
public function createPlatform()
{
return new SQLServer2008Platform();
}
public function testGeneratesTypeDeclarationForDateTimeTz()
{
self::assertEquals('DATETIMEOFFSET(6)', $this->platform->getDateTimeTzTypeDeclarationSQL([]));
}
}
......@@ -66,4 +66,9 @@ class SQLServerPlatformTest extends AbstractSQLServerPlatformTestCase
],
];
}
public function testGeneratesTypeDeclarationForDateTimeTz()
{
self::assertEquals('DATETIMEOFFSET(6)', $this->platform->getDateTimeTzTypeDeclarationSQL([]));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment