From 9b6b31cc047a55744816b28f5c0506146ad3832d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steve=20M=C3=BCller?= Date: Wed, 13 Feb 2013 18:58:53 +0100 Subject: [PATCH 1/4] Refactor SQL Server keyword dictionaries and MsSQL leftovers --- docs/en/reference/configuration.rst | 4 +- docs/en/reference/portability.rst | 2 +- lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php | 2 +- .../Keywords/SQLServer2005Keywords.php | 56 ++++ .../Keywords/SQLServer2008Keywords.php | 51 +++ .../Keywords/SQLServer2012Keywords.php | 9 +- ...sSQLKeywords.php => SQLServerKeywords.php} | 317 ++++++++---------- .../DBAL/Platforms/SQLServer2005Platform.php | 12 +- .../DBAL/Platforms/SQLServer2008Platform.php | 12 +- .../DBAL/Platforms/SQLServer2012Platform.php | 4 +- .../DBAL/Platforms/SQLServerPlatform.php | 8 +- .../Console/Command/ReservedWordsCommand.php | 8 +- 12 files changed, 298 insertions(+), 187 deletions(-) create mode 100644 lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2005Keywords.php create mode 100644 lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2008Keywords.php rename lib/Doctrine/DBAL/Platforms/Keywords/{MsSQLKeywords.php => SQLServerKeywords.php} (81%) diff --git a/docs/en/reference/configuration.rst b/docs/en/reference/configuration.rst index 6aa13a98787..e5b7d4b8c36 100644 --- a/docs/en/reference/configuration.rst +++ b/docs/en/reference/configuration.rst @@ -37,7 +37,7 @@ interfaces to use. It can be configured in one of three ways: - ``driver``: The built-in driver implementation to use. The following drivers are currently available: - + - ``pdo_mysql``: A MySQL driver that uses the pdo\_mysql PDO extension. - ``pdo_sqlite``: An SQLite driver that uses the pdo\_sqlite PDO @@ -47,7 +47,7 @@ interfaces to use. It can be configured in one of three ways: - ``pdo_oci``: An Oracle driver that uses the pdo\_oci PDO extension. **Note that this driver caused problems in our tests. Prefer the oci8 driver if possible.** - - ``pdo_sqlsrv``: An MSSQL driver that uses pdo\_sqlsrv PDO + - ``pdo_sqlsrv``: A Microsoft SQL Server driver that uses pdo\_sqlsrv PDO - ``oci8``: An Oracle driver that uses the oci8 PHP extension. - ``driverClass``: Specifies a custom driver implementation if no diff --git a/docs/en/reference/portability.rst b/docs/en/reference/portability.rst index 2b8dd15bef3..85246fa2207 100644 --- a/docs/en/reference/portability.rst +++ b/docs/en/reference/portability.rst @@ -4,7 +4,7 @@ Portability There are often cases when you need to write an application or library that is portable across multiple different database vendors. The Doctrine ORM is one example of such a library. It is an abstraction layer over all the currently supported vendors (MySQL, Oracle, -PostgreSQL, SQLite and MSSQL). If you want to use the DBAL to write a portable application +PostgreSQL, SQLite and Microsoft SQL Server). If you want to use the DBAL to write a portable application or library you have to follow lots of rules to make all the different vendors work the same. diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php b/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php index c7043cc6019..5b18b3562f1 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php @@ -50,7 +50,7 @@ public function connect(array $params, $username = null, $password = null, array public function getDatabasePlatform() { - return new \Doctrine\DBAL\Platforms\SQLServer2008Platform(); + return new \Doctrine\DBAL\Platforms\SQLServer2012Platform(); } public function getSchemaManager(\Doctrine\DBAL\Connection $conn) diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2005Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2005Keywords.php new file mode 100644 index 00000000000..3a7434910f3 --- /dev/null +++ b/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2005Keywords.php @@ -0,0 +1,56 @@ +. + */ + +namespace Doctrine\DBAL\Platforms\Keywords; + +/** + * Microsoft SQL Server 2005 reserved keyword dictionary. + * + * @license BSD http://www.opensource.org/licenses/bsd-license.php + * @link www.doctrine-project.com + * @since 2.3 + * @author Steve Müller + */ +class SQLServer2005Keywords extends SQLServerKeywords +{ + /** + * {@inheritdoc} + */ + public function getName() + { + return 'SQLServer2005'; + } + + /** + * {@inheritdoc} + * + * @link http://msdn.microsoft.com/en-US/library/ms189822%28v=sql.90%29.aspx + */ + protected function getKeywords() + { + return array_merge(array_diff(parent::getKeywords(), array('DUMMY')), array( + 'EXTERNAL', + 'PIVOT', + 'REVERT', + 'SECURITYAUDIT', + 'TABLESAMPLE', + 'UNPIVOT' + )); + } +} diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2008Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2008Keywords.php new file mode 100644 index 00000000000..38556b50557 --- /dev/null +++ b/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2008Keywords.php @@ -0,0 +1,51 @@ +. + */ + +namespace Doctrine\DBAL\Platforms\Keywords; + +/** + * Microsoft SQL Server 2008 reserved keyword dictionary. + * + * @license BSD http://www.opensource.org/licenses/bsd-license.php + * @link www.doctrine-project.com + * @since 2.3 + * @author Steve Müller + */ +class SQLServer2008Keywords extends SQLServer2005Keywords +{ + /** + * {@inheritdoc} + */ + public function getName() + { + return 'SQLServer2008'; + } + + /** + * {@inheritdoc} + * + * @link http://msdn.microsoft.com/en-us/library/ms189822%28v=sql.100%29.aspx + */ + protected function getKeywords() + { + return array_merge(parent::getKeywords(), array( + 'MERGE' + )); + } +} diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php index 2a7feaa4414..ada1c026bd7 100644 --- a/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php +++ b/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php @@ -20,14 +20,14 @@ namespace Doctrine\DBAL\Platforms\Keywords; /** - * SQL Server 2012 reserved keywords list. + * Microsoft SQL Server 2012 reserved keyword dictionary. * * @license BSD http://www.opensource.org/licenses/bsd-license.php * @link www.doctrine-project.com * @since 2.3 * @author Steve Müller */ -class SQLServer2012Keywords extends MsSQLKeywords +class SQLServer2012Keywords extends SQLServer2008Keywords { /** * {@inheritdoc} @@ -39,6 +39,8 @@ public function getName() /** * {@inheritdoc} + * + * @link http://msdn.microsoft.com/en-us/library/ms189822.aspx */ protected function getKeywords() { @@ -47,8 +49,7 @@ protected function getKeywords() 'SEMANTICSIMILARITYDETAILSTABLE', 'SEMANTICSIMILARITYTABLE', 'TRY_CONVERT', - 'WITHIN', - 'SEQUENCE' + 'WITHIN GROUP' )); } } diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/SQLServerKeywords.php similarity index 81% rename from lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php rename to lib/Doctrine/DBAL/Platforms/Keywords/SQLServerKeywords.php index aca3e4e1382..fb43d2d5313 100644 --- a/lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php +++ b/lib/Doctrine/DBAL/Platforms/Keywords/SQLServerKeywords.php @@ -17,234 +17,215 @@ * . */ - namespace Doctrine\DBAL\Platforms\Keywords; /** - * MsSQL Keywordlist + * Microsoft SQL Server 2000 reserved keyword dictionary. * - * @license BSD http://www.opensource.org/licenses/bsd-license.php - * @link www.doctrine-project.com - * @since 2.0 - * @author Benjamin Eberlei - * @author David Coallier - * @author Steve Müller + * @license BSD http://www.opensource.org/licenses/bsd-license.php + * @link www.doctrine-project.com + * @since 2.0 + * @author Benjamin Eberlei + * @author David Coallier + * @author Steve Müller */ -class MsSQLKeywords extends KeywordList +class SQLServerKeywords extends KeywordList { /** * {@inheritdoc} */ public function getName() { - return 'MsSQL'; + return 'SQLServer'; } /** * {@inheritdoc} + * + * @link http://msdn.microsoft.com/en-us/library/aa238507%28v=sql.80%29.aspx */ protected function getKeywords() { return array( 'ADD', - 'CURRENT_TIMESTAMP', - 'GROUP', - 'OPENQUERY', - 'SERIALIZABLE', 'ALL', - 'CURRENT_USER', - 'HAVING', - 'OPENROWSET', - 'SESSION_USER', 'ALTER', - 'CURSOR', - 'HOLDLOCK', - 'OPTION', - 'SET', 'AND', - 'DATABASE', - 'IDENTITY', - 'OR', - 'SETUSER', 'ANY', - 'DBCC', - 'IDENTITYCOL', - 'ORDER', - 'SHUTDOWN', 'AS', - 'DEALLOCATE', - 'IDENTITY_INSERT', - 'OUTER', - 'SOME', 'ASC', - 'DECLARE', - 'IF', - 'OVER', - 'STATISTICS', 'AUTHORIZATION', - 'DEFAULT', - 'IN', - 'PERCENT', - 'SUM', - 'AVG', - 'DELETE', - 'INDEX', - 'PERM', - 'SYSTEM_USER', 'BACKUP', - 'DENY', - 'INNER', - 'PERMANENT', - 'TABLE', 'BEGIN', - 'DESC', - 'INSERT', - 'PIPE', - 'TAPE', 'BETWEEN', - 'DISK', - 'INTERSECT', - 'PLAN', - 'TEMP', 'BREAK', - 'DISTINCT', - 'INTO', - 'PRECISION', - 'TEMPORARY', 'BROWSE', - 'DISTRIBUTED', - 'IS', - 'PREPARE', - 'TEXTSIZE', 'BULK', - 'DOUBLE', - 'ISOLATION', - 'PRIMARY', - 'THEN', 'BY', - 'DROP', - 'JOIN', - 'PRINT', - 'TO', 'CASCADE', - 'DUMMY', - 'KEY', - 'PRIVILEGES', - 'TOP', 'CASE', - 'DUMP', - 'KILL', - 'PROC', - 'TRAN', 'CHECK', - 'ELSE', - 'LEFT', - 'PROCEDURE', - 'TRANSACTION', 'CHECKPOINT', - 'END', - 'LEVEL', - 'PROCESSEXIT', - 'TRIGGER', 'CLOSE', - 'ERRLVL', - 'LIKE', - 'PUBLIC', - 'TRUNCATE', 'CLUSTERED', - 'ERROREXIT', - 'LINENO', - 'RAISERROR', - 'TSEQUAL', 'COALESCE', - 'ESCAPE', - 'LOAD', - 'READ', - 'UNCOMMITTED', + 'COLLATE', 'COLUMN', - 'EXCEPT', - 'MAX', - 'READTEXT', - 'UNION', 'COMMIT', + 'COMPUTE', + 'CONSTRAINT', + 'CONTAINS', + 'CONTAINSTABLE', + 'CONTINUE', + 'CONVERT', + 'CREATE', + 'CROSS', + 'CURRENT', + 'CURRENT_DATE', + 'CURRENT_TIME', + 'CURRENT_TIMESTAMP', + 'CURRENT_USER', + 'CURSOR', + 'DATABASE', + 'DBCC', + 'DEALLOCATE', + 'DECLARE', + 'DEFAULT', + 'DELETE', + 'DENY', + 'DESC', + 'DISK', + 'DISTINCT', + 'DISTRIBUTED', + 'DOUBLE', + 'DROP', + 'DUMP', + 'ELSE', + 'END', + 'ERRLVL', + 'ESCAPE', + 'EXCEPT', 'EXEC', - 'MIN', - 'RECONFIGURE', - 'UNIQUE', - 'COMMITTED', 'EXECUTE', - 'MIRROREXIT', - 'REFERENCES', - 'UPDATE', - 'COMPUTE', 'EXISTS', - 'NATIONAL', - 'REPEATABLE', - 'UPDATETEXT', - 'CONFIRM', 'EXIT', - 'NOCHECK', - 'REPLICATION', - 'USE', - 'CONSTRAINT', + 'EXTERNAL', 'FETCH', - 'NONCLUSTERED', - 'RESTORE', - 'USER', - 'CONTAINS', 'FILE', - 'NOT', - 'RESTRICT', - 'VALUES', - 'CONTAINSTABLE', 'FILLFACTOR', + 'FOR', + 'FOREIGN', + 'FREETEXT', + 'FREETEXTTABLE', + 'FROM', + 'FULL', + 'FUNCTION', + 'GOTO', + 'GRANT', + 'GROUP', + 'HAVING', + 'HOLDLOCK', + 'IDENTITY', + 'IDENTITY_INSERT', + 'IDENTITYCOL', + 'IF', + 'IN', + 'INDEX', + 'INNER', + 'INSERT', + 'INTERSECT', + 'INTO', + 'IS', + 'JOIN', + 'KEY', + 'KILL', + 'LEFT', + 'LIKE', + 'LINENO', + 'LOAD', + 'NATIONAL', + 'NOCHECK ', + 'NONCLUSTERED', + 'NOT', 'NULL', - 'RETURN', - 'VARYING', - 'CONTINUE', - 'FLOPPY', 'NULLIF', - 'REVOKE', - 'VIEW', - 'CONTROLROW', - 'FOR', 'OF', - 'RIGHT', - 'WAITFOR', - 'CONVERT', - 'FOREIGN', 'OFF', - 'ROLLBACK', - 'WHEN', - 'COUNT', - 'FREETEXT', 'OFFSETS', - 'ROWCOUNT', - 'WHERE', - 'CREATE', - 'FREETEXTTABLE', 'ON', + 'OPEN', + 'OPENDATASOURCE', + 'OPENQUERY', + 'OPENROWSET', + 'OPENXML', + 'OPTION', + 'OR', + 'ORDER', + 'OUTER', + 'OVER', + 'PERCENT', + 'PIVOT', + 'PLAN', + 'PRECISION', + 'PRIMARY', + 'PRINT', + 'PROC', + 'PROCEDURE', + 'PUBLIC', + 'RAISERROR', + 'READ', + 'READTEXT', + 'RECONFIGURE', + 'REFERENCES', + 'REPLICATION', + 'RESTORE', + 'RESTRICT', + 'RETURN', + 'REVERT', + 'REVOKE', + 'RIGHT', + 'ROLLBACK', + 'ROWCOUNT', 'ROWGUIDCOL', - 'WHILE', - 'CROSS', - 'FROM', - 'ONCE', 'RULE', - 'WITH', - 'CURRENT', - 'FULL', - 'ONLY', 'SAVE', - 'WORK', - 'CURRENT_DATE', - 'GOTO', - 'OPEN', 'SCHEMA', - 'WRITETEXT', - 'CURRENT_TIME', - 'GRANT', - 'OPENDATASOURCE', - 'SELECT' + 'SECURITYAUDIT', + 'SELECT', + 'SESSION_USER', + 'SET', + 'SETUSER', + 'SHUTDOWN', + 'SOME', + 'STATISTICS', + 'SYSTEM_USER', + 'TABLE', + 'TABLESAMPLE', + 'TEXTSIZE', + 'THEN', + 'TO', + 'TOP', + 'TRAN', + 'TRANSACTION', + 'TRIGGER', + 'TRUNCATE', + 'TSEQUAL', + 'UNION', + 'UNIQUE', + 'UNPIVOT', + 'UPDATE', + 'UPDATETEXT', + 'USE', + 'USER', + 'VALUES', + 'VARYING', + 'VIEW', + 'WAITFOR', + 'WHEN', + 'WHERE', + 'WHILE', + 'WITH', + 'WRITETEXT' ); } } diff --git a/lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php b/lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php index be3725b39c3..33c26ca51bb 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php @@ -20,7 +20,7 @@ namespace Doctrine\DBAL\Platforms; /** - * Platform to ensure compatibility of Doctrine with SQLServer2005 version and + * Platform to ensure compatibility of Doctrine with Microsoft SQL Server 2005 version and * higher. * * Differences to SQL Server 2008 are: @@ -50,5 +50,15 @@ public function getClobTypeDeclarationSQL(array $field) { return 'VARCHAR(MAX)'; } + + /** + * {@inheritdoc} + * + * Returns Microsoft SQL Server 2005 specific keywords class + */ + protected function getReservedKeywordsClass() + { + return 'Doctrine\DBAL\Platforms\Keywords\SQLServer2005Keywords'; + } } diff --git a/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php b/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php index 909ab84f839..8946854c1e9 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php @@ -20,7 +20,7 @@ namespace Doctrine\DBAL\Platforms; /** - * Platform to ensure compatibility of Doctrine with SQLServer2008 version. + * 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. @@ -97,4 +97,14 @@ protected function initializeDoctrineTypeMappings() $this->doctrineTypeMapping['date'] = 'date'; $this->doctrineTypeMapping['time'] = 'time'; } + + /** + * {@inheritdoc} + * + * Returns Microsoft SQL Server 2008 specific keywords class + */ + protected function getReservedKeywordsClass() + { + return 'Doctrine\DBAL\Platforms\Keywords\SQLServer2008Keywords'; + } } diff --git a/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php b/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php index 9b850db7e7e..d5c95705338 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php @@ -22,7 +22,7 @@ use Doctrine\DBAL\Schema\Sequence; /** - * Platform to ensure compatibility of Doctrine with SQLServer2012 version. + * Platform to ensure compatibility of Doctrine with Microsoft SQL Server 2012 version. * * Differences to SQL Server 2008 and before are that sequences are introduced. * @@ -88,6 +88,8 @@ public function supportsSequences() /** * {@inheritdoc} + * + * Returns Microsoft SQL Server 2012 specific keywords class */ protected function getReservedKeywordsClass() { diff --git a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php index 3688f57e673..37804cef187 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php @@ -82,8 +82,8 @@ public function getDateSubMonthExpression($date, $months) /** * {@inheritDoc} * - * MsSql prefers "autoincrement" identity columns since sequences can only - * be emulated with a table. + * Microsoft SQL Server prefers "autoincrement" identity columns + * since sequences can only be emulated with a table. */ public function prefersIdentityColumns() { @@ -93,7 +93,7 @@ public function prefersIdentityColumns() /** * {@inheritDoc} * - * MsSql supports this through AUTO_INCREMENT columns. + * Microsoft SQL Server supports this through AUTO_INCREMENT columns. */ public function supportsIdentityColumns() { @@ -903,7 +903,7 @@ public function getForUpdateSQL() */ protected function getReservedKeywordsClass() { - return 'Doctrine\DBAL\Platforms\Keywords\MsSQLKeywords'; + return 'Doctrine\DBAL\Platforms\Keywords\SQLServerKeywords'; } /** diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php index d1b1a8843fe..57ab21fced4 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php @@ -31,7 +31,7 @@ class ReservedWordsCommand extends Command { private $keywordListClasses = array( 'mysql' => 'Doctrine\DBAL\Platforms\Keywords\MySQLKeywords', - 'mssql' => 'Doctrine\DBAL\Platforms\Keywords\MsSQLKeywords', + 'sqlserver' => 'Doctrine\DBAL\Platforms\Keywords\SQLServerKeywords', 'sqlite' => 'Doctrine\DBAL\Platforms\Keywords\SQLiteKeywords', 'pgsql' => 'Doctrine\DBAL\Platforms\Keywords\PostgreSQLKeywords', 'oracle' => 'Doctrine\DBAL\Platforms\Keywords\OracleKeywords', @@ -66,7 +66,7 @@ protected function configure() Checks if the current database contains tables and columns with names that are identifiers in this dialect or in other SQL dialects. -By default SQLite, MySQL, PostgreSQL, MsSQL and Oracle +By default SQLite, MySQL, PostgreSQL, Microsoft SQL Server and Oracle keywords are checked: %command.full_name% @@ -82,7 +82,7 @@ protected function configure() * pgsql * sqlite * oracle - * mssql + * sqlserver * db2 (Not checked by default) EOT ); @@ -98,7 +98,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $keywordLists = (array)$input->getOption('list'); if ( ! $keywordLists) { - $keywordLists = array('mysql', 'pgsql', 'sqlite', 'oracle', 'mssql'); + $keywordLists = array('mysql', 'pgsql', 'sqlite', 'oracle', 'sqlserver'); } $keywords = array(); From 549b63431390f498db0a1f88591dbd901c3d5e4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steve=20M=C3=BCller?= Date: Wed, 13 Feb 2013 20:19:58 +0100 Subject: [PATCH 2/4] Readd MsSQLKeywords class for BC --- .../DBAL/Platforms/Keywords/MsSQLKeywords.php | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php new file mode 100644 index 00000000000..50f1c742c32 --- /dev/null +++ b/lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php @@ -0,0 +1,43 @@ +. + */ + + +namespace Doctrine\DBAL\Platforms\Keywords; + +/** + * MsSQL Keywordlist + * + * @license BSD http://www.opensource.org/licenses/bsd-license.php + * @link www.doctrine-project.com + * @since 2.0 + * @author Benjamin Eberlei + * @author David Coallier + * @author Steve Müller + * @deprecated Use SQLServerKeywords class instead. + */ +class MsSQLKeywords extends SQLServerKeywords +{ + /** + * {@inheritdoc} + */ + public function getName() + { + return 'MsSQL'; + } +} From dc2a03dfd5c15d50e5d561b0ffcc5cdb82714839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steve=20M=C3=BCller?= Date: Wed, 13 Feb 2013 20:21:09 +0100 Subject: [PATCH 3/4] Extend ReservedWordsCommand to respect new SQL Server keyword dictionaries --- .../Console/Command/ReservedWordsCommand.php | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php index 57ab21fced4..36184066937 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php @@ -30,12 +30,15 @@ class ReservedWordsCommand extends Command { private $keywordListClasses = array( - 'mysql' => 'Doctrine\DBAL\Platforms\Keywords\MySQLKeywords', - 'sqlserver' => 'Doctrine\DBAL\Platforms\Keywords\SQLServerKeywords', - 'sqlite' => 'Doctrine\DBAL\Platforms\Keywords\SQLiteKeywords', - 'pgsql' => 'Doctrine\DBAL\Platforms\Keywords\PostgreSQLKeywords', - 'oracle' => 'Doctrine\DBAL\Platforms\Keywords\OracleKeywords', - 'db2' => 'Doctrine\DBAL\Platforms\Keywords\DB2Keywords', + 'mysql' => 'Doctrine\DBAL\Platforms\Keywords\MySQLKeywords', + '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', + 'oracle' => 'Doctrine\DBAL\Platforms\Keywords\OracleKeywords', + 'db2' => 'Doctrine\DBAL\Platforms\Keywords\DB2Keywords', ); /** @@ -83,6 +86,9 @@ protected function configure() * sqlite * oracle * sqlserver + * sqlserver2005 + * sqlserver2008 + * sqlserver2012 * db2 (Not checked by default) EOT ); @@ -98,7 +104,16 @@ protected function execute(InputInterface $input, OutputInterface $output) $keywordLists = (array)$input->getOption('list'); if ( ! $keywordLists) { - $keywordLists = array('mysql', 'pgsql', 'sqlite', 'oracle', 'sqlserver'); + $keywordLists = array( + 'mysql', + 'pgsql', + 'sqlite', + 'oracle', + 'sqlserver', + 'sqlserver2005', + 'sqlserver2008', + 'sqlserver2012' + ); } $keywords = array(); From 7c1893cf5b68ffa4dde160b1911e2abe7afe1284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steve=20M=C3=BCller?= Date: Thu, 14 Feb 2013 09:16:25 +0100 Subject: [PATCH 4/4] Revert changing default SQL Server platform in driver --- lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php b/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php index 5b18b3562f1..c7043cc6019 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php @@ -50,7 +50,7 @@ public function connect(array $params, $username = null, $password = null, array public function getDatabasePlatform() { - return new \Doctrine\DBAL\Platforms\SQLServer2012Platform(); + return new \Doctrine\DBAL\Platforms\SQLServer2008Platform(); } public function getSchemaManager(\Doctrine\DBAL\Connection $conn)