Skip to content

Commit 060331a

Browse files
authored
Merge pull request #501 from nick-potts/main
Case insensitive CouldNotPersistAggregate::invalidVersion detection
2 parents 159255c + 8596d0a commit 060331a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/AggregateRoots/AggregateRoot.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Carbon\CarbonImmutable;
66
use Illuminate\Database\QueryException;
7+
use Illuminate\Database\UniqueConstraintViolationException;
78
use Illuminate\Support\Collection;
89
use Illuminate\Support\Facades\DB;
910
use Illuminate\Support\LazyCollection;
@@ -143,7 +144,7 @@ protected function persistWithoutApplyingToEventHandlers(): LazyCollection
143144
$this->uuid(),
144145
);
145146
} catch (QueryException $exception) {
146-
if (! str_contains($exception->getMessage(), 'Duplicate')) {
147+
if (! ($exception instanceof UniqueConstraintViolationException || str_contains($exception->getMessage(), 'Duplicate'))) {
147148
throw $exception;
148149
}
149150

0 commit comments

Comments
 (0)