Commit 01c5461f authored by Thomas Müller's avatar Thomas Müller

fix quoted sequence name

parent d8a96fcf
...@@ -494,7 +494,10 @@ BEGIN ...@@ -494,7 +494,10 @@ BEGIN
END IF; END IF;
END;'; END;';
$sequenceName = $this->getIdentitySequenceName($unquotedTableName, $unquotedName); $sequenceName = $this->getIdentitySequenceName(
$tableIdentifier->isQuoted() ? $quotedTableName : $unquotedTableName,
$nameIdentifier->isQuoted() ? $quotedName : $unquotedName
);
$sequence = new Sequence($sequenceName, $start); $sequence = new Sequence($sequenceName, $start);
$sql[] = $this->getCreateSequenceSQL($sequence); $sql[] = $this->getCreateSequenceSQL($sequence);
...@@ -512,7 +515,7 @@ BEGIN ...@@ -512,7 +515,7 @@ BEGIN
ELSE ELSE
SELECT NVL(Last_Number, 0) INTO last_Sequence SELECT NVL(Last_Number, 0) INTO last_Sequence
FROM User_Sequences FROM User_Sequences
WHERE Sequence_Name = \'' . $sequenceName . '\'; WHERE Sequence_Name = \'' . $sequence->getName() . '\';
SELECT :NEW.' . $quotedName . ' INTO last_InsertID FROM DUAL; SELECT :NEW.' . $quotedName . ' INTO last_InsertID FROM DUAL;
WHILE (last_InsertID > last_Sequence) LOOP WHILE (last_InsertID > last_Sequence) LOOP
SELECT ' . $sequenceName . '.NEXTVAL INTO last_Sequence FROM DUAL; SELECT ' . $sequenceName . '.NEXTVAL INTO last_Sequence FROM DUAL;
......
...@@ -602,4 +602,44 @@ class OraclePlatformTest extends AbstractPlatformTestCase ...@@ -602,4 +602,44 @@ class OraclePlatformTest extends AbstractPlatformTestCase
$this->_platform->getAlterTableSQL($tableDiff) $this->_platform->getAlterTableSQL($tableDiff)
); );
} }
public function testQuotedTableNames()
{
$table = new Table('"test"');
$table->addColumn('"id"', 'integer', array('autoincrement' => true));
// assert tabel
$this->assertTrue($table->isQuoted());
$this->assertEquals('test', $table->getName());
$this->assertEquals('"test"', $table->getQuotedName($this->_platform));
$sql = $this->_platform->getCreateTableSQL($table);
$this->assertEquals('CREATE TABLE "test" ("id" NUMBER(10) NOT NULL)', $sql[0]);
$this->assertEquals('CREATE SEQUENCE "test_SEQ" START WITH 1 MINVALUE 1 INCREMENT BY 1', $sql[2]);
$createTriggerStatement = <<<EOD
CREATE TRIGGER "test_AI_PK"
BEFORE INSERT
ON "test"
FOR EACH ROW
DECLARE
last_Sequence NUMBER;
last_InsertID NUMBER;
BEGIN
SELECT "test_SEQ".NEXTVAL INTO :NEW."id" FROM DUAL;
IF (:NEW."id" IS NULL OR :NEW."id" = 0) THEN
SELECT "test_SEQ".NEXTVAL INTO :NEW."id" FROM DUAL;
ELSE
SELECT NVL(Last_Number, 0) INTO last_Sequence
FROM User_Sequences
WHERE Sequence_Name = 'test_SEQ';
SELECT :NEW."id" INTO last_InsertID FROM DUAL;
WHILE (last_InsertID > last_Sequence) LOOP
SELECT "test_SEQ".NEXTVAL INTO last_Sequence FROM DUAL;
END LOOP;
END IF;
END;
EOD;
$this->assertEquals($createTriggerStatement, $sql[3]);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment