Skip to content

Commit

Permalink
fix oracle for name /w schema
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Jul 11, 2022
1 parent 84a60c3 commit 76412db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/Persistence/Sql/Oracle/PlatformTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,20 @@ public function getCreateAutoincrementSql($name, $table, $start = 1)
$sqls[count($sqls) - 1] = $conn->expr(
// else branch should be maybe (because of concurrency) put into after update trigger
str_replace('[pk_seq]', '\'' . str_replace('\'', '\'\'', $pkSeq) . '\'', <<<'EOT'
CREATE TRIGGER {trigger}
CREATE TRIGGER {{trigger}}
BEFORE INSERT OR UPDATE
ON {table}
ON {{table}}
FOR EACH ROW
DECLARE
atk4__pk_seq_last__ {table}.{pk}%TYPE;
atk4__pk_seq_last__ {{table}}.{pk}%TYPE;
BEGIN
IF (:NEW.{pk} IS NULL) THEN
SELECT {pk_seq}.NEXTVAL INTO :NEW.{pk} FROM DUAL;
SELECT {{pk_seq}}.NEXTVAL INTO :NEW.{pk} FROM DUAL;
ELSE
SELECT LAST_NUMBER INTO atk4__pk_seq_last__ FROM USER_SEQUENCES WHERE SEQUENCE_NAME = [pk_seq];
WHILE atk4__pk_seq_last__ <= :NEW.{pk}
LOOP
SELECT {pk_seq}.NEXTVAL + 1 INTO atk4__pk_seq_last__ FROM DUAL;
SELECT {{pk_seq}}.NEXTVAL + 1 INTO atk4__pk_seq_last__ FROM DUAL;
END LOOP;
END IF;
END;
Expand Down
12 changes: 8 additions & 4 deletions src/Schema/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function drop(): self
{
try {
$this->createSchemaManager()
->dropTable($this->getDatabasePlatform()->quoteIdentifier($this->table->getName()));
->dropTable($this->table->getQuotedName($this->getDatabasePlatform()));
} catch (DatabaseObjectNotFoundException $e) {
// fix exception not converted to TableNotFoundException for MSSQL
// https://github.com/doctrine/dbal/pull/5492
Expand Down Expand Up @@ -156,10 +156,14 @@ public function dropIfExists(): self
// but if AI trigger is not present, AI sequence is not dropped
// https://github.com/doctrine/dbal/issues/4997
if ($this->getDatabasePlatform() instanceof OraclePlatform) {
$dropTriggerSql = $this->getDatabasePlatform()->getDropAutoincrementSql($this->table->getName())[1];
$schemaManager = $this->createSchemaManager();
$dropTriggerSql = $this->getDatabasePlatform()
->getDropAutoincrementSql($this->table->getQuotedName($this->getDatabasePlatform()))[1];
try {
$this->getConnection()->expr($dropTriggerSql)->executeStatement();
} catch (Exception $e) {
\Closure::bind(function () use ($schemaManager, $dropTriggerSql) {
$schemaManager->_execSql($dropTriggerSql);
}, null, AbstractSchemaManager::class)();
} catch (DatabaseObjectNotFoundException $e) {
}
}

Expand Down

0 comments on commit 76412db

Please sign in to comment.