From c9a4a2f0d6250eb53b41c5d2c969ae470fa63f3f Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Tue, 24 Dec 2013 13:38:04 +0200 Subject: [PATCH] DBAL fixes --- .../Doctrine/DBAL/Platforms/MySqlPlatform.php | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php index dcb61c2423..cedd7054c8 100644 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php @@ -593,7 +593,7 @@ class MySqlPlatform extends AbstractPlatform $type = 'UNIQUE '; } - $query = 'ALTER TABLE ' . $table . ' DROP INDEX ' . $remIndex->getName() . ', '; + $query = 'ALTER TABLE ' . $this->espoQuote($table) . ' DROP INDEX ' . $remIndex->getName() . ', '; $query .= 'ADD ' . $type . 'INDEX ' . $addIndex->getName(); $query .= ' (' . $this->getIndexFieldDeclarationListSQL($addIndex->getQuotedColumns($this)) . ')'; @@ -713,7 +713,7 @@ class MySqlPlatform extends AbstractPlatform */ protected function getDropPrimaryKeySQL($table) { - return 'ALTER TABLE ' . $table . ' DROP PRIMARY KEY'; + return 'ALTER TABLE ' . $this->espoQuote($table) . ' DROP PRIMARY KEY'; } /** @@ -809,7 +809,7 @@ class MySqlPlatform extends AbstractPlatform throw new \InvalidArgumentException('getDropTableSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.'); } - return 'DROP TEMPORARY TABLE ' . $table; + return 'DROP TEMPORARY TABLE ' . $this->espoQuote($table); } /** @@ -898,5 +898,36 @@ class MySqlPlatform extends AbstractPlatform return $query; } + + public function getDropConstraintSQL($constraint, $table) + { + if ($constraint instanceof Constraint) { + $constraint = $constraint->getQuotedName($this); + } + + if ($table instanceof Table) { + $table = $table->getQuotedName($this); + } + + return 'ALTER TABLE ' . $this->espoQuote($table) . ' DROP CONSTRAINT ' . $constraint; + } + + public function getDropForeignKeySQL($foreignKey, $table) + { + if ($foreignKey instanceof ForeignKeyConstraint) { + $foreignKey = $foreignKey->getQuotedName($this); + } + + if ($table instanceof Table) { + $table = $table->getQuotedName($this); + } + + return 'ALTER TABLE ' . $this->espoQuote($table) . ' DROP FOREIGN KEY ' . $foreignKey; + } + + public function getCreatePrimaryKeySQL(Index $index, $table) + { + return 'ALTER TABLE ' . $this->espoQuote($table) . ' ADD PRIMARY KEY (' . $this->getIndexFieldDeclarationListSQL($index->getQuotedColumns($this)) . ')'; + } //end: ESPO }