Add missing default value for short url visits count

This commit is contained in:
Alejandro Celaya 2024-03-26 09:24:55 +01:00
parent 054eb42613
commit 6fbb5a380d
2 changed files with 25 additions and 21 deletions

View file

@ -28,6 +28,7 @@ return static function (ClassMetadata $metadata, array $emConfig): void {
$builder->createField('count', Types::BIGINT)
->columnName('count')
->option('unsigned', true)
->option('default', 1)
->build();
$builder->createField('slotId', Types::INTEGER)

View file

@ -117,9 +117,12 @@ final readonly class ShortUrlVisitsCountPreFlushListener
->setParameter('short_url_id', $shortUrlId)
->setParameter('potential_bot', $potentialBot)
->setParameter('slot_id', $slotId)
->forUpdate()
->setMaxResults(1);
if ($conn->getDatabasePlatform()::class === SQLServerPlatform::class) {
$qb->forUpdate();
}
$resultSet = $qb->executeQuery()->fetchOne();
$writeQb = ! $resultSet
? $conn->createQueryBuilder()