@@ -470,6 +470,18 @@ private function executeInsert(string $sql, array $parameters = [], array $types
470
470
if (!$ id ) {
471
471
throw new TransportException ('no id was returned by PostgreSQL from RETURNING clause. ' );
472
472
}
473
+ } elseif ($ this ->driverConnection ->getDatabasePlatform () instanceof OraclePlatform) {
474
+ $ sequenceName = 'seq_ ' .$ this ->configuration ['table_name ' ];
475
+
476
+ $ this ->driverConnection ->executeStatement ($ sql , $ parameters , $ types );
477
+
478
+ $ result = $ this ->driverConnection ->fetchOne ('SELECT ' .$ sequenceName .'.CURRVAL FROM DUAL ' );
479
+
480
+ $ id = (int ) $ result ;
481
+
482
+ if (!$ id ) {
483
+ throw new TransportException ('no id was returned by Oracle from sequence: ' .$ sequenceName );
484
+ }
473
485
} else {
474
486
$ this ->driverConnection ->executeStatement ($ sql , $ parameters , $ types );
475
487
@@ -507,7 +519,7 @@ private function addTableToSchema(Schema $schema): void
507
519
$ table = $ schema ->createTable ($ this ->configuration ['table_name ' ]);
508
520
// add an internal option to mark that we created this & the non-namespaced table name
509
521
$ table ->addOption (self ::TABLE_OPTION_NAME , $ this ->configuration ['table_name ' ]);
510
- $ table ->addColumn ('id ' , Types::BIGINT )
522
+ $ idColumn = $ table ->addColumn ('id ' , Types::BIGINT )
511
523
->setAutoincrement (true )
512
524
->setNotnull (true );
513
525
$ table ->addColumn ('body ' , Types::TEXT )
@@ -527,6 +539,13 @@ private function addTableToSchema(Schema $schema): void
527
539
$ table ->addIndex (['queue_name ' ]);
528
540
$ table ->addIndex (['available_at ' ]);
529
541
$ table ->addIndex (['delivered_at ' ]);
542
+
543
+ // We need to create a sequence for Oracle and set the id column to get the correct nextval
544
+ if ($ this ->driverConnection ->getDatabasePlatform () instanceof OraclePlatform) {
545
+ $ idColumn ->setDefault ('seq_ ' .$ this ->configuration ['table_name ' ].'.nextval ' );
546
+
547
+ $ schema ->createSequence ('seq_ ' .$ this ->configuration ['table_name ' ]);
548
+ }
530
549
}
531
550
532
551
private function decodeEnvelopeHeaders (array $ doctrineEnvelope ): array
0 commit comments