Skip to content
This repository

[DC-1037] Quote identifiers when getting/setting Migration version #41

Open
wants to merge 1 commit into from

1 participant

John Kary
John Kary

This is a fix for ticket DC-1037:
http://www.doctrine-project.org/jira/browse/DC-1037

Without this patch, Migrations are fully broken for some databases (at least Oracle) when using quoted identifiers connection option.

This patch quotes identifiers used to generate raw SQL commands used in Doctrine_Migration.

I don't think this would present any type of backwards compatibility issues since we weren't quoting identifiers before, and there is no way to catch/modify the query before it is executed during the migration process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Sep 07, 2011
John Kary [DC-1037] Quote identifiers when getting/setting Migration version 9f0eb05
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 4 additions and 4 deletions. Show diff stats Hide diff stats

  1. 8  lib/Doctrine/Migration.php
8  lib/Doctrine/Migration.php
@@ -226,9 +226,9 @@ public function getMigrationClasses()
226 226
     public function setCurrentVersion($number)
227 227
     {
228 228
         if ($this->hasMigrated()) {
229  
-            $this->_connection->exec("UPDATE " . $this->_migrationTableName . " SET version = $number");
  229
+            $this->_connection->exec("UPDATE " . $this->_connection->quoteIdentifier($this->_migrationTableName, true) . " SET " . $this->_connection->quoteIdentifier('version', true) . " = $number");
230 230
         } else {
231  
-            $this->_connection->exec("INSERT INTO " . $this->_migrationTableName . " (version) VALUES ($number)");
  231
+            $this->_connection->exec("INSERT INTO " . $this->_connection->quoteIdentifier($this->_migrationTableName, true) . " (" . $this->_connection->quoteIdentifier('version', true) . ") VALUES ($number)");
232 232
         }
233 233
     }
234 234
 
@@ -241,7 +241,7 @@ public function getCurrentVersion()
241 241
     {
242 242
         $this->_createMigrationTable();
243 243
 
244  
-        $result = $this->_connection->fetchColumn("SELECT version FROM " . $this->_migrationTableName);
  244
+        $result = $this->_connection->fetchColumn("SELECT " . $this->_connection->quoteIdentifier('version', true) . " FROM " . $this->_connection->quoteIdentifier($this->_migrationTableName, true));
245 245
 
246 246
         return isset($result[0]) ? $result[0]:0;
247 247
     }
@@ -255,7 +255,7 @@ public function hasMigrated()
255 255
     {
256 256
         $this->_createMigrationTable();
257 257
 
258  
-        $result = $this->_connection->fetchColumn("SELECT version FROM " . $this->_migrationTableName);
  258
+        $result = $this->_connection->fetchColumn("SELECT " . $this->_connection->quoteIdentifier('version', true) . " FROM " . $this->_connection->quoteIdentifier($this->_migrationTableName, true));
259 259
 
260 260
         return isset($result[0]) ? true:false;
261 261
     }
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.