Skip to content

Commit

Permalink
Now we aren't guessing check constraint names
Browse files Browse the repository at this point in the history
but getting the real ones under MSSQL. MDL-9356
  • Loading branch information
stronk7 committed Sep 11, 2007
1 parent f0dfc20 commit 92529a7
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/xmldb/classes/generators/mssql/mssql.class.php
Expand Up @@ -368,14 +368,21 @@ function getCreateEnumSQL($xmldb_table, $xmldb_field) {
' ADD ' . $this->getEnumExtraSQL($xmldb_table, $xmldb_field));
}

/**
* Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its enum
/**
* Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its enum
* (usually invoked from getModifyEnumSQL()
*/
function getDropEnumSQL($xmldb_table, $xmldb_field) {
/// All we have to do is to drop the check constraint
return array('ALTER TABLE ' . $this->getTableName($xmldb_table) .
' DROP CONSTRAINT ' . $this->getNameForObject($xmldb_table->getName(), $xmldb_field->getName(), 'ck'));
/// Let's introspect to know the real name of the check constraint
if ($check_constraints = $this->getCheckConstraintsFromDB($xmldb_table, $xmldb_field)) {
$check_constraint = array_shift($check_constraints); /// Get the 1st (should be only one)
$constraint_name = strtolower($check_constraint->name); /// Extract the REAL name
/// All we have to do is to drop the check constraint
return array('ALTER TABLE ' . $this->getTableName($xmldb_table) .
' DROP CONSTRAINT ' . $constraint_name);
} else { /// Constraint not found. Nothing to do
return array();
}
}

/**
Expand Down

0 comments on commit 92529a7

Please sign in to comment.