Quote identifiers on mysql
This commit is contained in:
parent
6f71419f2b
commit
c6053b2830
2 changed files with 35 additions and 1 deletions
|
@ -64,7 +64,9 @@ class MDB2SchemaManager {
|
|||
return new SQLiteMigrator($this->conn);
|
||||
} else if ($platform instanceof OraclePlatform) {
|
||||
return new OracleMigrator($this->conn);
|
||||
} else if ($platform instanceof MySqlPlatform or $platform instanceof PostgreSqlPlatform) {
|
||||
} else if ($platform instanceof MySqlPlatform) {
|
||||
return new MySQLMigrator($this->conn);
|
||||
} else if ($platform instanceof PostgreSqlPlatform) {
|
||||
return new Migrator($this->conn);
|
||||
} else {
|
||||
return new NoCheckMigrator($this->conn);
|
||||
|
|
32
lib/private/db/mysqlmigrator.php
Normal file
32
lib/private/db/mysqlmigrator.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
namespace OC\DB;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
class MySQLMigrator extends Migrator {
|
||||
/**
|
||||
* @param Schema $targetSchema
|
||||
* @param \Doctrine\DBAL\Connection $connection
|
||||
* @return \Doctrine\DBAL\Schema\SchemaDiff
|
||||
*/
|
||||
protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
|
||||
$schemaDiff = parent::getDiff($targetSchema, $connection);
|
||||
|
||||
// identifiers need to be quoted for mysql
|
||||
foreach ($schemaDiff->changedTables as $tableDiff) {
|
||||
$tableDiff->name = $this->connection->quoteIdentifier($tableDiff->name);
|
||||
foreach ($tableDiff->changedColumns as $column) {
|
||||
$column->oldColumnName = $this->connection->quoteIdentifier($column->oldColumnName);
|
||||
}
|
||||
}
|
||||
|
||||
return $schemaDiff;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue