Description
Symfony version(s) affected
6.4.12
Description
Error Message
IdentityColumnsNotSupported > DriverException > TransportException : An exception occurred in the driver: The driver does not support identity columns.
Context
Usage of async symfony/messenger with doctrine as transport
Explanation
When dealing with an Oracle database, the dispatched message is well inserted into the database but an exception is encountered when trying to get the last inserted id. That exception lead to a rollback and therefore a failing process of queing the messages.
IDs are generated with sequence instead of identity column as you have it with MySQL database for exemple.
A specific treatment is needed as done for PostgreSQL database
How to reproduce
Environment
- PHP 8.3
- Symfony 6.4.12
- OS : Windows
- DB : Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0
- Extensions: oci_8_19, ...
How to reproduce
- Set up a project
- Create a symfony web project
- Create a Controller/route to use as test
- Check symfony/messenger works well as sync
- Install symfony/messenger if not installed
- Create a message and it's handler and test the dispatch and execution of the hander
- Test symfony/messenger works well as async
- Install symfony/doctrine-messenger
- Set the process as async
When testing the async process, the error should appear as the message can't be recorded into the database
Possible Solution
Target the OraclePlatform to get the last inserted id as needed for that database :
...
elseif ($this->driverConnection->getDatabasePlatform() instanceof OraclePlatform) {
$sequenceName = strtoupper($this->configuration['table_name'].'_seq');
$this->driverConnection->executeStatement($sql, $parameters, $types);
$result = $this->driverConnection->fetchOne('select last_number from user_sequences where sequence_name = \''.$sequenceName.'\'');
$id = (int) $result;
if (!$id) {
throw new TransportException('no id was found in Oracle for sequence: '.$sequenceName);
}
}
...
Important :
- On GitHub, for the 6.4.x version, a solution is implemented but doesn't work and produce an error (ORA-02289). Should be adapted as shown above
- Maybe it is in beta as the deployed version on my machine doesn't have that elseif block !
- Fix should also be ported to symfony/doctrine-messenger 7.1.x
Additional Context
No response