From 7ae81563894b971e51cee7bdb0ac2da83ecc5149 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 21 Jun 2013 12:21:14 +0200 Subject: [PATCH] Fix quoting of identifiers in OraclePlatform --- .../DBAL/Platforms/OraclePlatform.php | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php index cac6d9d9..6a16ac31 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php @@ -355,8 +355,6 @@ protected function _getCreateTableSQL($table, array $columns, array $options = a */ public function getListTableIndexesSQL($table, $currentDatabase = null) { - $table = strtoupper($table); - return "SELECT uind.index_name AS name, " . " uind.index_type AS type, " . " decode( uind.uniqueness, 'NONUNIQUE', 0, 'UNIQUE', 1 ) AS is_unique, " . @@ -392,7 +390,7 @@ public function getDropViewSQL($name) public function getCreateAutoincrementSql($name, $table, $start = 1) { - $table = strtoupper($table); + $table = $this->getOracleInternalName($table); $sql = array(); $indexName = $table . '_AI_PK'; @@ -408,11 +406,14 @@ public function getCreateAutoincrementSql($name, $table, $start = 1) END IF; END;'; - $sequenceName = $table . '_SEQ'; + $sequenceNameNotQuoted = $table . '_SEQ'; + $sequenceName = $this->quoteIdentifier($sequenceNameNotQuoted); $sequence = new Sequence($sequenceName, $start); $sql[] = $this->getCreateSequenceSQL($sequence); $triggerName = $table . '_AI_PK'; + $triggerName = $this->quoteIdentifier($triggerName); + $table = $this->quoteIdentifier($table); $sql[] = 'CREATE TRIGGER ' . $triggerName . ' BEFORE INSERT ON ' . $table . ' @@ -427,7 +428,7 @@ public function getCreateAutoincrementSql($name, $table, $start = 1) ELSE SELECT NVL(Last_Number, 0) INTO last_Sequence FROM User_Sequences - WHERE Sequence_Name = \'' . $sequenceName . '\'; + WHERE Sequence_Name = \'' . $sequenceNameNotQuoted . '\'; SELECT :NEW.' . $name . ' INTO last_InsertID FROM DUAL; WHILE (last_InsertID > last_Sequence) LOOP SELECT ' . $sequenceName . '.NEXTVAL INTO last_Sequence FROM DUAL; @@ -440,7 +441,7 @@ public function getCreateAutoincrementSql($name, $table, $start = 1) public function getDropAutoincrementSql($table) { - $table = strtoupper($table); + $table = $this->getOracleInternalName($table); $trigger = $table . '_AI_PK'; $sql[] = 'DROP TRIGGER ' . $trigger; @@ -454,7 +455,7 @@ public function getDropAutoincrementSql($table) public function getListTableForeignKeysSQL($table) { - $table = strtoupper($table); + $table = $this->getOracleInternalName($table); return "SELECT alc.constraint_name, alc.DELETE_RULE, @@ -478,14 +479,12 @@ public function getListTableForeignKeysSQL($table) public function getListTableConstraintsSQL($table) { - $table = strtoupper($table); + $table = $this->getOracleInternalName($table); return 'SELECT * FROM user_constraints WHERE table_name = \'' . $table . '\''; } public function getListTableColumnsSQL($table, $database = null) { - $table = strtoupper($table); - $tabColumnsTableName = "user_tab_columns"; $ownerCondition = ''; @@ -823,4 +822,12 @@ public function getBlobTypeDeclarationSQL(array $field) { return 'BLOB'; } + + protected function getOracleInternalName($table) + { + if ($table[0] == '"') { + return str_replace(array('`', '"'), '', $table); + } + return strtoupper($table); + } }