diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php index 9c759e4ec82..fe8b6444a9a 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php @@ -142,7 +142,7 @@ public function exec(string $statement) : int public function lastInsertId(string $name = null) : string { if ($name === null) { - return false; + throw new OCI8Exception('A sequence name must be provided.'); } $sql = 'SELECT ' . $name . '.CURRVAL FROM DUAL'; diff --git a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php index e5de4046031..dd23771b61e 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\DBAL\Functional; use DateTime; +use Doctrine\DBAL\Driver\OCI8\OCI8Exception; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\Sequence; @@ -189,7 +190,10 @@ public function testLastInsertIdNoSequenceGiven() $this->markTestSkipped("Test only works consistently on platforms that support sequences and don't support identity columns."); } - self::assertSame('', $this->connection->lastInsertId(null)); + $this->expectException(OCI8Exception::class); + $this->expectExceptionMessage('A sequence name must be provided.'); + + $this->connection->lastInsertId(null); } /**