]> source.dussan.org Git - nextcloud-server.git/commitdiff
Quote identifiers on mysql
authorRobin Appelman <icewind@owncloud.com>
Tue, 6 May 2014 12:46:59 +0000 (14:46 +0200)
committerRobin Appelman <icewind@owncloud.com>
Tue, 3 Jun 2014 09:18:45 +0000 (11:18 +0200)
lib/private/db/mdb2schemamanager.php
lib/private/db/mysqlmigrator.php [new file with mode: 0644]

index 1a19e737da86bae65654fd89e0c519fa30dcbab3..d6e0e77b54e42f5afbd62120f1c26ac98e814370 100644 (file)
@@ -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);
diff --git a/lib/private/db/mysqlmigrator.php b/lib/private/db/mysqlmigrator.php
new file mode 100644 (file)
index 0000000..97495f5
--- /dev/null
@@ -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;
+       }
+}