Skip to content

Commit 76412db

Browse files
committed
fix oracle for name /w schema
1 parent 84a60c3 commit 76412db

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/Persistence/Sql/Oracle/PlatformTrait.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,20 @@ public function getCreateAutoincrementSql($name, $table, $start = 1)
6868
$sqls[count($sqls) - 1] = $conn->expr(
6969
// else branch should be maybe (because of concurrency) put into after update trigger
7070
str_replace('[pk_seq]', '\'' . str_replace('\'', '\'\'', $pkSeq) . '\'', <<<'EOT'
71-
CREATE TRIGGER {trigger}
71+
CREATE TRIGGER {{trigger}}
7272
BEFORE INSERT OR UPDATE
73-
ON {table}
73+
ON {{table}}
7474
FOR EACH ROW
7575
DECLARE
76-
atk4__pk_seq_last__ {table}.{pk}%TYPE;
76+
atk4__pk_seq_last__ {{table}}.{pk}%TYPE;
7777
BEGIN
7878
IF (:NEW.{pk} IS NULL) THEN
79-
SELECT {pk_seq}.NEXTVAL INTO :NEW.{pk} FROM DUAL;
79+
SELECT {{pk_seq}}.NEXTVAL INTO :NEW.{pk} FROM DUAL;
8080
ELSE
8181
SELECT LAST_NUMBER INTO atk4__pk_seq_last__ FROM USER_SEQUENCES WHERE SEQUENCE_NAME = [pk_seq];
8282
WHILE atk4__pk_seq_last__ <= :NEW.{pk}
8383
LOOP
84-
SELECT {pk_seq}.NEXTVAL + 1 INTO atk4__pk_seq_last__ FROM DUAL;
84+
SELECT {{pk_seq}}.NEXTVAL + 1 INTO atk4__pk_seq_last__ FROM DUAL;
8585
END LOOP;
8686
END IF;
8787
END;

src/Schema/Migrator.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function drop(): self
126126
{
127127
try {
128128
$this->createSchemaManager()
129-
->dropTable($this->getDatabasePlatform()->quoteIdentifier($this->table->getName()));
129+
->dropTable($this->table->getQuotedName($this->getDatabasePlatform()));
130130
} catch (DatabaseObjectNotFoundException $e) {
131131
// fix exception not converted to TableNotFoundException for MSSQL
132132
// https://github.com/doctrine/dbal/pull/5492
@@ -156,10 +156,14 @@ public function dropIfExists(): self
156156
// but if AI trigger is not present, AI sequence is not dropped
157157
// https://github.com/doctrine/dbal/issues/4997
158158
if ($this->getDatabasePlatform() instanceof OraclePlatform) {
159-
$dropTriggerSql = $this->getDatabasePlatform()->getDropAutoincrementSql($this->table->getName())[1];
159+
$schemaManager = $this->createSchemaManager();
160+
$dropTriggerSql = $this->getDatabasePlatform()
161+
->getDropAutoincrementSql($this->table->getQuotedName($this->getDatabasePlatform()))[1];
160162
try {
161-
$this->getConnection()->expr($dropTriggerSql)->executeStatement();
162-
} catch (Exception $e) {
163+
\Closure::bind(function () use ($schemaManager, $dropTriggerSql) {
164+
$schemaManager->_execSql($dropTriggerSql);
165+
}, null, AbstractSchemaManager::class)();
166+
} catch (DatabaseObjectNotFoundException $e) {
163167
}
164168
}
165169

0 commit comments

Comments
 (0)