]> source.dussan.org Git - nextcloud-server.git/commitdiff
Quote index columns that need it
authorBart Visscher <bartv@thisnet.nl>
Sun, 17 Mar 2013 16:00:07 +0000 (17:00 +0100)
committerBart Visscher <bartv@thisnet.nl>
Sun, 17 Mar 2013 16:00:07 +0000 (17:00 +0100)
lib/db/mdb2schemareader.php
lib/db/schema.php

index 1d71af1700cfcdcd8a4803422e1e43fd055085b7..827323a5512d0d5564109010013d666d43d35c2c 100644 (file)
@@ -9,10 +9,12 @@
 class OC_DB_MDB2SchemaReader {
        static protected $DBNAME;
        static protected $DBTABLEPREFIX;
+       static protected $platform;
 
-       public static function loadSchemaFromFile($file) {
+       public static function loadSchemaFromFile($file, $platform) {
                self::$DBNAME  = OC_Config::getValue( "dbname", "owncloud" );
                self::$DBTABLEPREFIX = OC_Config::getValue( "dbtableprefix", "oc_" );
+               self::$platform = $platform;
                $schema = new \Doctrine\DBAL\Schema\Schema();
                $xml = simplexml_load_file($file);
                foreach($xml->children() as $child) {
@@ -173,6 +175,10 @@ class OC_DB_MDB2SchemaReader {
                                                switch($field->getName()) {
                                                        case 'name':
                                                                $field_name = (string)$field;
+                                                               $keywords = self::$platform->getReservedKeywordsList();
+                                                               if ($keywords->isKeyword($field_name)) {
+                                                                       $field_name = self::$platform->quoteIdentifier($field_name);
+                                                               }
                                                                $fields[] = $field_name;
                                                                break;
                                                        case 'sorting':
index cd356e7ff83ff89963eebbeff085f93924b23d8f..7a1ec204044dd2af5157f4318bdd7dd1933da846 100644 (file)
@@ -32,7 +32,7 @@ class OC_DB_Schema {
         * TODO: write more documentation
         */
        public static function createDbFromStructure( $conn, $file ) {
-               $toSchema = OC_DB_MDB2SchemaReader::loadSchemaFromFile($file);
+               $toSchema = OC_DB_MDB2SchemaReader::loadSchemaFromFile($file, $conn->getDatabasePlatform());
                return self::executeSchemaChange($conn, $toSchema);
        }
 
@@ -45,7 +45,7 @@ class OC_DB_Schema {
                $sm = $conn->getSchemaManager();
                $fromSchema = $sm->createSchema();
 
-               $toSchema = OC_DB_MDB2SchemaReader::loadSchemaFromFile($file);
+               $toSchema = OC_DB_MDB2SchemaReader::loadSchemaFromFile($file, $conn->getDatabasePlatform());
 
                // remove tables we don't know about
                foreach($fromSchema->getTables() as $table) {
@@ -84,7 +84,7 @@ class OC_DB_Schema {
         * @param string $file the xml file describing the tables
         */
        public static function removeDBStructure($conn, $file) {
-               $fromSchema = OC_DB_MDB2SchemaReader::loadSchemaFromFile($file);
+               $fromSchema = OC_DB_MDB2SchemaReader::loadSchemaFromFile($file, $conn->getDatabasePlatform());
                $toSchema = clone $fromSchema;
                foreach($toSchema->getTables() as $table) {
                        $toSchema->dropTable($table->getName());