mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-23887 database: fix use of deprecated system tables for mssql
Catalog views are available which we should use instead.
This commit is contained in:
parent
3fa531ea2c
commit
fa2a9cc933
@ -544,9 +544,9 @@ class mssql_sql_generator extends sql_generator {
|
||||
$fieldname = $xmldb_field->getName();
|
||||
|
||||
// Look for any default constraint in this field and drop it
|
||||
if ($default = $this->mdb->get_record_sql("SELECT id, object_name(cdefault) AS defaultconstraint
|
||||
FROM syscolumns
|
||||
WHERE id = object_id(?)
|
||||
if ($default = $this->mdb->get_record_sql("SELECT object_id, object_name(default_object_id) AS defaultconstraint
|
||||
FROM sys.columns
|
||||
WHERE object_id = object_id(?)
|
||||
AND name = ?", array($tablename, $fieldname))) {
|
||||
return $default->defaultconstraint;
|
||||
} else {
|
||||
@ -603,7 +603,7 @@ class mssql_sql_generator extends sql_generator {
|
||||
case 'fk':
|
||||
case 'ck':
|
||||
if ($check = $this->mdb->get_records_sql("SELECT name
|
||||
FROM sysobjects
|
||||
FROM sys.objects
|
||||
WHERE lower(name) = ?", array(strtolower($object_name)))) {
|
||||
return true;
|
||||
}
|
||||
@ -611,7 +611,7 @@ class mssql_sql_generator extends sql_generator {
|
||||
case 'ix':
|
||||
case 'uix':
|
||||
if ($check = $this->mdb->get_records_sql("SELECT name
|
||||
FROM sysindexes
|
||||
FROM sys.indexes
|
||||
WHERE lower(name) = ?", array(strtolower($object_name)))) {
|
||||
return true;
|
||||
}
|
||||
|
@ -481,8 +481,8 @@ class mssql_native_moodle_database extends moodle_database {
|
||||
quotename(table_name)), column_name, 'IsIdentity') AS auto_increment,
|
||||
column_default AS default_value
|
||||
FROM tempdb.INFORMATION_SCHEMA.COLUMNS
|
||||
JOIN tempdb..sysobjects ON name = table_name
|
||||
WHERE id = object_id('tempdb..{" . $table . "}')
|
||||
JOIN tempdb.sys.objects ON name = table_name
|
||||
WHERE object_id = object_id('tempdb..{" . $table . "}')
|
||||
ORDER BY ordinal_position";
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user