BUG: Fixed MSSQL index name generation for tables with \ in the name.

Right now the name of a table with a namespace will contain a '\' character.  The internal index name generated clashes with this, so we've dealt with it by turning the '\' into a '_'
This commit is contained in:
Sam Minnee 2012-06-26 14:52:18 +12:00
parent 22d53b036b
commit 05e706ea18
1 changed files with 2 additions and 2 deletions

View File

@ -830,9 +830,9 @@ class MSSQLDatabase extends SS_Database {
* Return SQL for dropping and recreating an index
*/
protected function getIndexSqlDefinition($tableName, $indexName, $indexSpec) {
$index = 'ix_' . $tableName . '_' . $indexName;
$index = 'ix_' . str_replace('\\', '_', $tableName) . '_' . $indexName;
$drop = "IF EXISTS (SELECT name FROM sys.indexes WHERE name = '$index') DROP INDEX $index ON \"" . $tableName . "\";";
if(!is_array($indexSpec)) {
$indexSpec=trim($indexSpec, '()');
return "$drop CREATE INDEX $index ON \"" . $tableName . "\" (" . $indexSpec . ");";