Fix duplicate key messages for MySQL >= 8.0.19
[MAILPOET-2642]
This commit is contained in:
committed by
Jack Kitterhing
parent
dc7e87a67f
commit
996b58a388
@ -232,7 +232,7 @@ class Model extends \MailPoetVendor\Sudzy\ValidModel {
|
|||||||
} catch (\PDOException $e) {
|
} catch (\PDOException $e) {
|
||||||
switch ($e->getCode()) {
|
switch ($e->getCode()) {
|
||||||
case 23000:
|
case 23000:
|
||||||
preg_match("/for key \'(.*?)\'/i", $e->getMessage(), $matches);
|
preg_match("/for key '(?:.*\.)*(.*?)'/i", $e->getMessage(), $matches);
|
||||||
if (isset($matches[1])) {
|
if (isset($matches[1])) {
|
||||||
$column = $matches[1];
|
$column = $matches[1];
|
||||||
$this->setError(
|
$this->setError(
|
||||||
|
@ -79,7 +79,7 @@ class SegmentsTest extends \MailPoetTest {
|
|||||||
|
|
||||||
$response = $this->endpoint->save($duplicateEntry);
|
$response = $this->endpoint->save($duplicateEntry);
|
||||||
expect($response->status)->equals(APIResponse::STATUS_BAD_REQUEST);
|
expect($response->status)->equals(APIResponse::STATUS_BAD_REQUEST);
|
||||||
expect($response->errors[0]['message'])->regExp('/Another record already exists. Please specify a different ".*name"./');
|
expect($response->errors[0]['message'])->equals('Another record already exists. Please specify a different "name".');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItCanRestoreASegment() {
|
public function testItCanRestoreASegment() {
|
||||||
|
@ -49,6 +49,7 @@ class SaverTest extends \MailPoetTest {
|
|||||||
]);
|
]);
|
||||||
$this->expectException('\MailPoet\DynamicSegments\Exceptions\ErrorSavingException');
|
$this->expectException('\MailPoet\DynamicSegments\Exceptions\ErrorSavingException');
|
||||||
$this->expectExceptionCode(Model::DUPLICATE_RECORD);
|
$this->expectExceptionCode(Model::DUPLICATE_RECORD);
|
||||||
|
$this->expectExceptionMessage('Another record already exists. Please specify a different "PRIMARY".');
|
||||||
$this->saver->save($dynamicSegment2);
|
$this->saver->save($dynamicSegment2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user