Skip to content

Commit

Permalink
fixup!
Browse files Browse the repository at this point in the history
  • Loading branch information
hgraca committed Sep 14, 2023
1 parent 89f1572 commit e4a7610
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
15 changes: 7 additions & 8 deletions src/Id/TableGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\LockMode;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\Deprecations\Deprecation;
use Throwable;

Expand Down Expand Up @@ -116,12 +114,13 @@ public function nextValue($sequence)
$this->conn->beginTransaction();

try {
$platform = $this->conn->getDatabasePlatform();
$sql = 'SELECT sequence_value, sequence_increment_by'
. ' FROM ' . $platform->appendLockHint($this->generatorTableName, LockMode::PESSIMISTIC_WRITE)
. ' WHERE sequence_name = ? '
. ($platform instanceof SQLServerPlatform ? '' : $platform->getWriteLockSQL());
$row = $this->conn->fetchAssociative($sql, [$sequence]);
$qb = $this->conn->createQueryBuilder();
$sql = $qb->select('t.sequence_value', 't.sequence_increment_by')
->from($this->generatorTableName, 't')
->where('t.sequence_name = ?')
->lockForUpdate()
->getSQL();
$row = $this->conn->fetchAssociative($sql, [$sequence]);

if ($row !== false) {
$row = array_change_key_case($row, CASE_LOWER);
Expand Down
4 changes: 1 addition & 3 deletions src/Query/QueryLockBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
use function rtrim;
use function trim;

/**
* @internal
*/
/** @internal */
final class QueryLockBuilder
{
public const FOR_UPDATE = 'FOR_UPDATE';
Expand Down

0 comments on commit e4a7610

Please sign in to comment.