From 05e706ea189357c00e230b4cbff1e169f6c1c264 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Tue, 26 Jun 2012 14:52:18 +1200 Subject: [PATCH] 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 '_' --- code/MSSQLDatabase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/MSSQLDatabase.php b/code/MSSQLDatabase.php index 0a33316..7967185 100644 --- a/code/MSSQLDatabase.php +++ b/code/MSSQLDatabase.php @@ -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 . ");";