Skip to content

[Doctrine][Messenger] Use common sequence name to get id from Oracle #54566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Doctrine][Messenger] Use common sequence name to get id from Oracle
  • Loading branch information
rjd22 authored and fabpot committed Oct 6, 2024
commit 52c3a32ca96a627f681c00ee0cc8ff6ade8a1b0d
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,18 @@ private function executeInsert(string $sql, array $parameters = [], array $types
if (!$id) {
throw new TransportException('no id was returned by PostgreSQL from RETURNING clause.');
}
} elseif ($this->driverConnection->getDatabasePlatform() instanceof OraclePlatform) {
$sequenceName = 'seq_'.$this->configuration['table_name'];

$this->driverConnection->executeStatement($sql, $parameters, $types);

$result = $this->driverConnection->fetchOne('SELECT '.$sequenceName.'.CURRVAL FROM DUAL');

$id = (int) $result;

if (!$id) {
throw new TransportException('no id was returned by Oracle from sequence: '.$sequenceName);
}
} else {
$this->driverConnection->executeStatement($sql, $parameters, $types);

Expand Down Expand Up @@ -507,7 +519,7 @@ private function addTableToSchema(Schema $schema): void
$table = $schema->createTable($this->configuration['table_name']);
// add an internal option to mark that we created this & the non-namespaced table name
$table->addOption(self::TABLE_OPTION_NAME, $this->configuration['table_name']);
$table->addColumn('id', Types::BIGINT)
$idColumn = $table->addColumn('id', Types::BIGINT)
->setAutoincrement(true)
->setNotnull(true);
$table->addColumn('body', Types::TEXT)
Expand All @@ -527,6 +539,13 @@ private function addTableToSchema(Schema $schema): void
$table->addIndex(['queue_name']);
$table->addIndex(['available_at']);
$table->addIndex(['delivered_at']);

// We need to create a sequence for Oracle and set the id column to get the correct nextval
if ($this->driverConnection->getDatabasePlatform() instanceof OraclePlatform) {
$idColumn->setDefault('seq_'.$this->configuration['table_name'].'.nextval');

$schema->createSequence('seq_'.$this->configuration['table_name']);
}
}

private function decodeEnvelopeHeaders(array $doctrineEnvelope): array
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy