mirror of
https://github.com/silverstripe/silverstripe-mssql
synced 2024-10-22 08:05:53 +02:00
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:
parent
22d53b036b
commit
05e706ea18
@ -830,9 +830,9 @@ class MSSQLDatabase extends SS_Database {
|
|||||||
* Return SQL for dropping and recreating an index
|
* Return SQL for dropping and recreating an index
|
||||||
*/
|
*/
|
||||||
protected function getIndexSqlDefinition($tableName, $indexName, $indexSpec) {
|
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 . "\";";
|
$drop = "IF EXISTS (SELECT name FROM sys.indexes WHERE name = '$index') DROP INDEX $index ON \"" . $tableName . "\";";
|
||||||
|
|
||||||
if(!is_array($indexSpec)) {
|
if(!is_array($indexSpec)) {
|
||||||
$indexSpec=trim($indexSpec, '()');
|
$indexSpec=trim($indexSpec, '()');
|
||||||
return "$drop CREATE INDEX $index ON \"" . $tableName . "\" (" . $indexSpec . ");";
|
return "$drop CREATE INDEX $index ON \"" . $tableName . "\" (" . $indexSpec . ");";
|
||||||
|
Loading…
Reference in New Issue
Block a user