Commit ffff175c authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge branch 'DBAL-126'

parents 2f4d10b2 a880811a
......@@ -20,7 +20,9 @@
namespace Doctrine\DBAL\Platforms;
use Doctrine\DBAL\DBALException,
Doctrine\DBAL\Schema\TableDiff;
Doctrine\DBAL\Schema\TableDiff,
Doctrine\DBAL\Schema\Index,
Doctrine\DBAL\Schema\Table;
/**
* The MySqlPlatform provides the behavior, features and SQL dialect of the
......@@ -577,19 +579,36 @@ class MySqlPlatform extends AbstractPlatform
*/
public function getDropIndexSQL($index, $table=null)
{
if($index instanceof \Doctrine\DBAL\Schema\Index) {
$index = $index->getQuotedName($this);
} else if(!is_string($index)) {
if($index instanceof Index) {
$indexName = $index->getQuotedName($this);
} else if(is_string($index)) {
$indexName = $index;
} else {
throw new \InvalidArgumentException('MysqlPlatform::getDropIndexSQL() expects $index parameter to be string or \Doctrine\DBAL\Schema\Index.');
}
if($table instanceof \Doctrine\DBAL\Schema\Table) {
if($table instanceof Table) {
$table = $table->getQuotedName($this);
} else if(!is_string($table)) {
throw new \InvalidArgumentException('MysqlPlatform::getDropIndexSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.');
}
return 'DROP INDEX ' . $index . ' ON ' . $table;
if ($index instanceof Index && $index->isPrimary()) {
// mysql primary keys are always named "PRIMARY",
// so we cannot use them in statements because of them being keyword.
return $this->getDropPrimaryKeySQL($table);
}
return 'DROP INDEX ' . $indexName . ' ON ' . $table;
}
/**
* @param Index $index
* @param Table $table
*/
protected function getDropPrimaryKeySQL($table)
{
return 'ALTER TABLE ' . $table . ' DROP PRIMARY KEY';
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment