From 8bfcf683ee7c81b8496f92f4c9e40fb0ca440745 Mon Sep 17 00:00:00 2001 From: Rob Bayliss Date: Sun, 11 Jan 2015 15:57:02 -0500 Subject: [PATCH] Fix unique index exception handling for an index on multiple columns in PHP 5.4 --- lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php | 1 + tests/Doctrine/Tests/DBAL/Driver/AbstractSQLiteDriverTest.php | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php index b01b79b4c4d..0facc9b8154 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php @@ -42,6 +42,7 @@ public function convertException($message, DriverException $exception) { if (strpos($exception->getMessage(), 'must be unique') !== false || strpos($exception->getMessage(), 'is not unique') !== false || + strpos($exception->getMessage(), 'are not unique') !== false || strpos($exception->getMessage(), 'UNIQUE constraint failed') !== false ) { return new Exception\UniqueConstraintViolationException($message, $exception); diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLiteDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLiteDriverTest.php index 537cc48e199..04644f71bce 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLiteDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLiteDriverTest.php @@ -71,6 +71,7 @@ protected function getExceptionConversionData() self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => array( array(null, null, 'must be unique'), array(null, null, 'is not unique'), + array(null, null, 'are not unique'), ), ); }