Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 49b57f0

Browse filesBrowse files
committed
[Messenger] Fix Oracle errors 'ORA-00955: Name is already used by an existing object' with Doctrine transport
1 parent 91ed2eb commit 49b57f0
Copy full SHA for 49b57f0

File tree

1 file changed

+10
-3
lines changed
Filter options
  • src/Symfony/Component/Messenger/Bridge/Doctrine/Transport

1 file changed

+10
-3
lines changed

‎src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php
+10-3Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ public function setup(): void
302302
throw new \TypeError(\sprintf('The table name must be an instance of "%s" or a string ("%s" given).', AbstractAsset::class, get_debug_type($tableName)));
303303
}
304304

305-
return $tableName === $this->configuration['table_name'];
305+
// SchemaAssetsFilter needs to match the messenger table name and also the messenger sequence name to make $schemaDiff work correctly in updateSchema()
306+
// This may also work for other databases if their sequence name is suffixed with '_seq', '_id_seq' or similar.
307+
return str_starts_with($tableName, $this->configuration['table_name']); // MESSENGER_MESSAGES*
306308
});
307309
$this->updateSchema();
308310
$configuration->setSchemaAssetsFilter($assetFilter);
@@ -533,9 +535,14 @@ private function addTableToSchema(Schema $schema): void
533535

534536
// We need to create a sequence for Oracle and set the id column to get the correct nextval
535537
if ($this->driverConnection->getDatabasePlatform() instanceof OraclePlatform) {
536-
$idColumn->setDefault($this->configuration['table_name'].self::ORACLE_SEQUENCES_SUFFIX.'.nextval');
538+
$serverVersion = $this->driverConnection->getWrappedConnection()->getServerVersion();
539+
if (version_compare($serverVersion, '12.1.0', '>=')) {
540+
$idColumn->setAutoincrement(false); // disable the creation of SEQUENCE and TRIGGER
541+
// The line below is taken into account only if Oracle version is >= 12.1.0
542+
$idColumn->setDefault($this->configuration['table_name'].self::ORACLE_SEQUENCES_SUFFIX.'.nextval');
537543

538-
$schema->createSequence($this->configuration['table_name'].self::ORACLE_SEQUENCES_SUFFIX);
544+
$schema->createSequence($this->configuration['table_name'].self::ORACLE_SEQUENCES_SUFFIX);
545+
}
539546
}
540547
}
541548

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.