mirror of
https://github.com/moodle/moodle.git
synced 2025-04-24 18:04:43 +02:00
Now MSSQL naming of objects introspects to avoid duplicates. MDL-7376
This commit is contained in:
parent
c15816ce95
commit
3b34bc7f39
@ -464,6 +464,37 @@ class XMLDBmssql extends XMLDBgenerator {
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given one object name and it's type (pk, uk, fk, ck, ix, uix, seq, trg)
|
||||
* return if such name is currently in use (true) or no (false)
|
||||
* (invoked from getNameForObject()
|
||||
*/
|
||||
function isNameInUse($object_name, $type) {
|
||||
switch($type) {
|
||||
case 'seq':
|
||||
case 'trg':
|
||||
case 'pk':
|
||||
case 'uk':
|
||||
case 'fk':
|
||||
case 'ck':
|
||||
if ($check = get_records_sql("SELECT name
|
||||
FROM sysobjects
|
||||
WHERE lower(name) = '" . strtolower($object_name) . "'")) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 'ix':
|
||||
case 'uix':
|
||||
if ($check = get_records_sql("SELECT name
|
||||
FROM sysindexes
|
||||
WHERE lower(name) = '" . strtolower($object_name) . "'")) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false; //No name in use found
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of reserved words (lowercase) for this DB
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user