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

Drop support for SQL Server <2008

parent 50375f96
...@@ -8,6 +8,19 @@ All implementations of the `PingableConnection` and `ServerInfoAwareConnection` ...@@ -8,6 +8,19 @@ All implementations of the `PingableConnection` and `ServerInfoAwareConnection`
All implementations of the `VersionAwarePlatformDriver` interface have to implement the methods defined in the `Driver` interface as well. All implementations of the `VersionAwarePlatformDriver` interface have to implement the methods defined in the `Driver` interface as well.
## 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 ## 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. DBAL now requires PostgeSQL 9.3 or newer, support for unmaintained versions has been dropped.
......
...@@ -50,9 +50,7 @@ Oracle ...@@ -50,9 +50,7 @@ Oracle
Microsoft SQL Server Microsoft SQL Server
^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^
- ``SQLServerPlatform`` for version 2000 and above (deprecated). - ``SQLServerPlatform`` for version 2008 and above.
- ``SQLServer2005Platform`` for version 2005 and above (deprecated).
- ``SQLServer2008Platform`` for version 2008 and above (deprecated).
- ``SQLServer2012Platform`` for version 2012 and above. - ``SQLServer2012Platform`` for version 2012 and above.
PostgreSQL PostgreSQL
......
...@@ -701,9 +701,7 @@ Please also notice the mapping specific footnotes for additional information. ...@@ -701,9 +701,7 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+ | | | | +--------------------------+ | |
| | | **Drizzle** | | | | | | **Drizzle** | | |
| | +--------------------------+---------+ | | | +--------------------------+---------+ |
| | | **SQL Server** | >= 2008 | | | | | **SQL Server** | "all" | |
| | | +---------+----------------------------------------------------------+
| | | | < 2008 | ``DATETIME`` [16]_ |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+ +-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **datetime** | ``\DateTime`` | **MySQL** | *all* | ``DATETIME`` [13]_ | | **datetime** | ``\DateTime`` | **MySQL** | *all* | ``DATETIME`` [13]_ |
| | +--------------------------+ +----------------------------------------------------------+ | | +--------------------------+ +----------------------------------------------------------+
...@@ -725,9 +723,7 @@ Please also notice the mapping specific footnotes for additional information. ...@@ -725,9 +723,7 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+ | | | | +--------------------------+ | |
| | | **SQLite** | | | | | | **SQLite** | | |
| | +--------------------------+---------+ | | | +--------------------------+---------+ |
| | | **SQL Server** | < 2008 | | | | | **SQL Server** | "all" | |
| | | +---------+----------------------------------------------------------+
| | | | >= 2008 | ``DATETIMEOFFSET(6)`` |
| | +--------------------------+---------+----------------------------------------------------------+ | | +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | *all* | ``TIMESTAMP(0) WITH TIME ZONE`` | | | | **PostgreSQL** | *all* | ``TIMESTAMP(0) WITH TIME ZONE`` |
| | +--------------------------+ | | | | +--------------------------+ | |
...@@ -749,9 +745,7 @@ Please also notice the mapping specific footnotes for additional information. ...@@ -749,9 +745,7 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+---------+----------------------------------------------------------+ | | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``DATE`` [16]_ | | | | **Oracle** | *all* | ``DATE`` [16]_ |
| | +--------------------------+---------+----------------------------------------------------------+ | | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Server** | < 2008 | ``DATETIME`` [16]_ | | | | **SQL Server** | "all" | ``TIME(0)`` |
| | | +---------+----------------------------------------------------------+
| | | | >= 2008 | ``TIME(0)`` |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+ +-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **array** [1]_ | ``array`` | **MySQL** | *all* | ``TINYTEXT`` [17]_ | | **array** [1]_ | ``array`` | **MySQL** | *all* | ``TINYTEXT`` [17]_ |
+-------------------+ | | +----------------------------------------------------------+ +-------------------+ | | +----------------------------------------------------------+
......
...@@ -4,8 +4,6 @@ namespace Doctrine\DBAL\Driver; ...@@ -4,8 +4,6 @@ namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\SQLServer2005Platform;
use Doctrine\DBAL\Platforms\SQLServer2008Platform;
use Doctrine\DBAL\Platforms\SQLServer2012Platform; use Doctrine\DBAL\Platforms\SQLServer2012Platform;
use Doctrine\DBAL\Platforms\SQLServerPlatform; use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Schema\SQLServerSchemaManager; use Doctrine\DBAL\Schema\SQLServerSchemaManager;
...@@ -43,10 +41,6 @@ abstract class AbstractSQLServerDriver implements VersionAwarePlatformDriver ...@@ -43,10 +41,6 @@ abstract class AbstractSQLServerDriver implements VersionAwarePlatformDriver
switch (true) { switch (true) {
case version_compare($version, '11.00.2100', '>='): case version_compare($version, '11.00.2100', '>='):
return new SQLServer2012Platform(); return new SQLServer2012Platform();
case version_compare($version, '10.00.1600', '>='):
return new SQLServer2008Platform();
case version_compare($version, '9.00.1399', '>='):
return new SQLServer2005Platform();
default: default:
return new SQLServerPlatform(); return new SQLServerPlatform();
} }
...@@ -67,7 +61,7 @@ abstract class AbstractSQLServerDriver implements VersionAwarePlatformDriver ...@@ -67,7 +61,7 @@ abstract class AbstractSQLServerDriver implements VersionAwarePlatformDriver
*/ */
public function getDatabasePlatform() public function getDatabasePlatform()
{ {
return new SQLServer2008Platform(); return new SQLServerPlatform();
} }
/** /**
......
...@@ -9,7 +9,7 @@ use function array_merge; ...@@ -9,7 +9,7 @@ use function array_merge;
* *
* @link www.doctrine-project.com * @link www.doctrine-project.com
*/ */
class SQLServer2012Keywords extends SQLServer2008Keywords class SQLServer2012Keywords extends SQLServerKeywords
{ {
/** /**
* {@inheritdoc} * {@inheritdoc}
......
...@@ -121,6 +121,7 @@ class SQLServerKeywords extends KeywordList ...@@ -121,6 +121,7 @@ class SQLServerKeywords extends KeywordList
'LIKE', 'LIKE',
'LINENO', 'LINENO',
'LOAD', 'LOAD',
'MERGE',
'NATIONAL', 'NATIONAL',
'NOCHECK ', 'NOCHECK ',
'NONCLUSTERED', 'NONCLUSTERED',
......
<?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.
*
* @deprecated Use SQL Server 2012 or newer
*/
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;
}
}
...@@ -10,7 +10,7 @@ namespace Doctrine\DBAL\Platforms; ...@@ -10,7 +10,7 @@ namespace Doctrine\DBAL\Platforms;
* *
* @deprecated Use SQL Server 2012 or newer * @deprecated Use SQL Server 2012 or newer
*/ */
class SQLServer2008Platform extends SQLServer2005Platform class SQLServer2008Platform extends SQLServerPlatform
{ {
/** /**
* {@inheritDoc} * {@inheritDoc}
......
...@@ -14,7 +14,7 @@ use function substr_count; ...@@ -14,7 +14,7 @@ use function substr_count;
* Differences to SQL Server 2008 and before are that sequences are introduced, * 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. * and support for the new OFFSET... FETCH syntax for result pagination has been added.
*/ */
class SQLServer2012Platform extends SQLServer2008Platform class SQLServer2012Platform extends SQLServerPlatform
{ {
/** /**
* {@inheritdoc} * {@inheritdoc}
......
...@@ -38,8 +38,6 @@ use function substr_count; ...@@ -38,8 +38,6 @@ use function substr_count;
/** /**
* The SQLServerPlatform provides the behavior, features and SQL dialect of the * The SQLServerPlatform provides the behavior, features and SQL dialect of the
* Microsoft SQL Server database platform. * Microsoft SQL Server database platform.
*
* @deprecated Use SQL Server 2012 or newer
*/ */
class SQLServerPlatform extends AbstractPlatform class SQLServerPlatform extends AbstractPlatform
{ {
...@@ -898,7 +896,7 @@ SQL ...@@ -898,7 +896,7 @@ SQL
{ {
// "sysdiagrams" table must be ignored as it's internal SQL Server table for Database Diagrams // "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 // 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";
} }
/** /**
...@@ -1186,6 +1184,14 @@ SQL ...@@ -1186,6 +1184,14 @@ SQL
return 'UNIQUEIDENTIFIER'; return 'UNIQUEIDENTIFIER';
} }
/**
* {@inheritDoc}
*/
public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)
{
return 'DATETIMEOFFSET(6)';
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
...@@ -1231,7 +1237,9 @@ SQL ...@@ -1231,7 +1237,9 @@ SQL
*/ */
public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration) public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
{ {
return 'DATETIME'; // 3 - microseconds precision length
// http://msdn.microsoft.com/en-us/library/ms187819.aspx
return 'DATETIME2(6)';
} }
/** /**
...@@ -1239,7 +1247,7 @@ SQL ...@@ -1239,7 +1247,7 @@ SQL
*/ */
public function getDateTypeDeclarationSQL(array $fieldDeclaration) public function getDateTypeDeclarationSQL(array $fieldDeclaration)
{ {
return 'DATETIME'; return 'DATE';
} }
/** /**
...@@ -1247,7 +1255,7 @@ SQL ...@@ -1247,7 +1255,7 @@ SQL
*/ */
public function getTimeTypeDeclarationSQL(array $fieldDeclaration) public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
{ {
return 'DATETIME'; return 'TIME(0)';
} }
/** /**
...@@ -1396,7 +1404,7 @@ SQL ...@@ -1396,7 +1404,7 @@ SQL
*/ */
public function supportsLimitOffset() public function supportsLimitOffset()
{ {
return false; return true;
} }
/** /**
...@@ -1440,7 +1448,7 @@ SQL ...@@ -1440,7 +1448,7 @@ SQL
*/ */
public function getDateTimeFormatString() public function getDateTimeFormatString()
{ {
return 'Y-m-d H:i:s.000'; return 'Y-m-d H:i:s.u';
} }
/** /**
...@@ -1448,7 +1456,7 @@ SQL ...@@ -1448,7 +1456,7 @@ SQL
*/ */
public function getDateFormatString() public function getDateFormatString()
{ {
return 'Y-m-d H:i:s.000'; return 'Y-m-d';
} }
/** /**
...@@ -1456,7 +1464,7 @@ SQL ...@@ -1456,7 +1464,7 @@ SQL
*/ */
public function getTimeFormatString() public function getTimeFormatString()
{ {
return 'Y-m-d H:i:s.000'; return 'H:i:s';
} }
/** /**
...@@ -1464,7 +1472,7 @@ SQL ...@@ -1464,7 +1472,7 @@ SQL
*/ */
public function getDateTimeTzFormatString() public function getDateTimeTzFormatString()
{ {
return $this->getDateTimeFormatString(); return 'Y-m-d H:i:s.u P';
} }
/** /**
...@@ -1506,6 +1514,10 @@ SQL ...@@ -1506,6 +1514,10 @@ SQL
'varbinary' => 'binary', 'varbinary' => 'binary',
'image' => 'blob', 'image' => 'blob',
'uniqueidentifier' => 'guid', 'uniqueidentifier' => 'guid',
'datetime2' => 'datetime',
'date' => 'date',
'time' => 'time',
'datetimeoffset' => 'datetimetz',
]; ];
} }
...@@ -1636,6 +1648,14 @@ SQL ...@@ -1636,6 +1648,14 @@ SQL
return $name . ' ' . $columnDef; return $name . ' ' . $columnDef;
} }
/**
* {@inheritdoc}
*/
protected function getLikeWildcardCharacters() : string
{
return parent::getLikeWildcardCharacters() . '[]^';
}
/** /**
* Returns a unique default constraint name for a table and column. * Returns a unique default constraint name for a table and column.
* *
......
...@@ -17,8 +17,6 @@ use Doctrine\DBAL\Platforms\Keywords\SQLAnywhere12Keywords; ...@@ -17,8 +17,6 @@ use Doctrine\DBAL\Platforms\Keywords\SQLAnywhere12Keywords;
use Doctrine\DBAL\Platforms\Keywords\SQLAnywhere16Keywords; use Doctrine\DBAL\Platforms\Keywords\SQLAnywhere16Keywords;
use Doctrine\DBAL\Platforms\Keywords\SQLAnywhereKeywords; use Doctrine\DBAL\Platforms\Keywords\SQLAnywhereKeywords;
use Doctrine\DBAL\Platforms\Keywords\SQLiteKeywords; 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\SQLServer2012Keywords;
use Doctrine\DBAL\Platforms\Keywords\SQLServerKeywords; use Doctrine\DBAL\Platforms\Keywords\SQLServerKeywords;
use InvalidArgumentException; use InvalidArgumentException;
...@@ -38,8 +36,6 @@ class ReservedWordsCommand extends Command ...@@ -38,8 +36,6 @@ class ReservedWordsCommand extends Command
'mysql57' => MySQL57Keywords::class, 'mysql57' => MySQL57Keywords::class,
'mysql80' => MySQL80Keywords::class, 'mysql80' => MySQL80Keywords::class,
'sqlserver' => SQLServerKeywords::class, 'sqlserver' => SQLServerKeywords::class,
'sqlserver2005' => SQLServer2005Keywords::class,
'sqlserver2008' => SQLServer2008Keywords::class,
'sqlserver2012' => SQLServer2012Keywords::class, 'sqlserver2012' => SQLServer2012Keywords::class,
'sqlite' => SQLiteKeywords::class, 'sqlite' => SQLiteKeywords::class,
'pgsql' => PostgreSQLKeywords::class, 'pgsql' => PostgreSQLKeywords::class,
...@@ -106,8 +102,6 @@ The following keyword lists are currently shipped with Doctrine: ...@@ -106,8 +102,6 @@ The following keyword lists are currently shipped with Doctrine:
* sqlite * sqlite
* oracle * oracle
* sqlserver * sqlserver
* sqlserver2005
* sqlserver2008
* sqlserver2012 * sqlserver2012
* sqlanywhere * sqlanywhere
* sqlanywhere11 * sqlanywhere11
......
...@@ -6,8 +6,6 @@ use Doctrine\DBAL\Connection; ...@@ -6,8 +6,6 @@ use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractSQLServerDriver; use Doctrine\DBAL\Driver\AbstractSQLServerDriver;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\SQLServer2005Platform;
use Doctrine\DBAL\Platforms\SQLServer2008Platform;
use Doctrine\DBAL\Platforms\SQLServer2012Platform; use Doctrine\DBAL\Platforms\SQLServer2012Platform;
use Doctrine\DBAL\Platforms\SQLServerPlatform; use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\AbstractSchemaManager;
...@@ -22,7 +20,7 @@ class AbstractSQLServerDriverTest extends AbstractDriverTest ...@@ -22,7 +20,7 @@ class AbstractSQLServerDriverTest extends AbstractDriverTest
protected function createPlatform() : AbstractPlatform protected function createPlatform() : AbstractPlatform
{ {
return new SQLServer2008Platform(); return new SQLServerPlatform();
} }
protected function createSchemaManager(Connection $connection) : AbstractSchemaManager protected function createSchemaManager(Connection $connection) : AbstractSchemaManager
...@@ -36,27 +34,19 @@ class AbstractSQLServerDriverTest extends AbstractDriverTest ...@@ -36,27 +34,19 @@ class AbstractSQLServerDriverTest extends AbstractDriverTest
protected function getDatabasePlatformsForVersions() : array protected function getDatabasePlatformsForVersions() : array
{ {
return [ return [
['9', SQLServerPlatform::class], ['10', SQLServerPlatform::class],
['9.00', SQLServerPlatform::class], ['10.00', SQLServerPlatform::class],
['9.00.0', SQLServerPlatform::class], ['10.00.0', SQLServerPlatform::class],
['9.00.1398', SQLServerPlatform::class], ['10.00.1599', SQLServerPlatform::class],
['9.00.1398.99', SQLServerPlatform::class], ['10.00.1599.99', SQLServerPlatform::class],
['9.00.1399', SQLServer2005Platform::class], ['10.00.1600', SQLServerPlatform::class],
['9.00.1399.0', SQLServer2005Platform::class], ['10.00.1600.0', SQLServerPlatform::class],
['9.00.1399.99', SQLServer2005Platform::class], ['10.00.1600.99', SQLServerPlatform::class],
['9.00.1400', SQLServer2005Platform::class], ['10.00.1601', SQLServerPlatform::class],
['9.10', SQLServer2005Platform::class], ['10.10', SQLServerPlatform::class],
['9.10.9999', SQLServer2005Platform::class], ['10.10.9999', SQLServerPlatform::class],
['10.00.1599', SQLServer2005Platform::class], ['11.00.2099', SQLServerPlatform::class],
['10.00.1599.99', SQLServer2005Platform::class], ['11.00.2099.99', SQLServerPlatform::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],
['11.00.2100', SQLServer2012Platform::class], ['11.00.2100', SQLServer2012Platform::class],
['11.00.2100.0', SQLServer2012Platform::class], ['11.00.2100.0', SQLServer2012Platform::class],
['11.00.2100.99', SQLServer2012Platform::class], ['11.00.2100.99', SQLServer2012Platform::class],
......
...@@ -75,4 +75,9 @@ class SQLServerPlatformTest extends AbstractSQLServerPlatformTestCase ...@@ -75,4 +75,9 @@ class SQLServerPlatformTest extends AbstractSQLServerPlatformTestCase
], ],
]; ];
} }
public function testGeneratesTypeDeclarationForDateTimeTz() : void
{
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