mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Annihilate one wrong use of getNameForObject() now
that we are able to detect REAL check constraints names
This commit is contained in:
parent
da40b0beab
commit
dc6cc11a72
1 changed files with 6 additions and 9 deletions
|
@ -154,7 +154,8 @@ class XMLDBmssql extends XMLDBgenerator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop the field from the table
|
* Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop the field from the table
|
||||||
* MSSQL overwrites the standard sentence because it needs to do some extra work dropping the default constraints
|
* MSSQL overwrites the standard sentence because it needs to do some extra work dropping the default and
|
||||||
|
* check constraints
|
||||||
*/
|
*/
|
||||||
function getDropFieldSQL($xmldb_table, $xmldb_field) {
|
function getDropFieldSQL($xmldb_table, $xmldb_field) {
|
||||||
|
|
||||||
|
@ -166,21 +167,17 @@ class XMLDBmssql extends XMLDBgenerator {
|
||||||
$tablename = $this->getTableName($xmldb_table);
|
$tablename = $this->getTableName($xmldb_table);
|
||||||
$fieldname = $this->getEncQuoted($xmldb_field->getName());
|
$fieldname = $this->getEncQuoted($xmldb_field->getName());
|
||||||
|
|
||||||
$checkconsname = $this->getNameForObject($xmldb_table->getName(), $xmldb_field->getName(), 'ck');
|
|
||||||
|
|
||||||
/// Look for any default constraint in this field and drop it
|
/// Look for any default constraint in this field and drop it
|
||||||
if ($defaultname = $this->getDefaultConstraintName($xmldb_table, $xmldb_field)) {
|
if ($defaultname = $this->getDefaultConstraintName($xmldb_table, $xmldb_field)) {
|
||||||
$results[] = 'ALTER TABLE ' . $tablename . ' DROP CONSTRAINT ' . $defaultname;
|
$results[] = 'ALTER TABLE ' . $tablename . ' DROP CONSTRAINT ' . $defaultname;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Look for any check constraint in this field and drop it
|
/// Look for any check constraint in this field and drop it
|
||||||
if ($check = get_record_sql("SELECT id, object_name(constid) AS checkconstraint
|
if ($drop_check = $this->getDropEnumSQL($xmldb_table, $xmldb_field)) {
|
||||||
FROM sysconstraints
|
$results = array_merge($results, $drop_check);
|
||||||
WHERE id = object_id('{$tablename}') AND
|
|
||||||
object_name(constid) = '$checkconsname'")) {
|
|
||||||
$results[] = 'ALTER TABLE ' . $tablename . ' DROP CONSTRAINT ' . $check->checkconstraint;
|
|
||||||
}
|
}
|
||||||
/// Build the standard alter table drop
|
|
||||||
|
/// Build the standard alter table drop column
|
||||||
$results[] = 'ALTER TABLE ' . $tablename . ' DROP COLUMN ' . $fieldname;
|
$results[] = 'ALTER TABLE ' . $tablename . ' DROP COLUMN ' . $fieldname;
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue