Skip to content

Commit

Permalink
use uuid v7 only if supported
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Aug 3, 2024
1 parent a72bdc9 commit 35f2273
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Action/SqlActionAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ protected function getData(RecordInterface $body, Connection $connection, Table
}

if ($insert && $column->getName() === $primaryKey && $column->getType() instanceof GuidType && $value === null) {
$value = Uuid::v7()->toString();
if (method_exists(Uuid::class, 'v7')) {
$value = Uuid::v7()->toString();
} else {
$value = Uuid::v4()->toString();
}
}

if ($value === null && $column->getNotnull()) {
Expand Down

0 comments on commit 35f2273

Please sign in to comment.