Skip to content

Commit

Permalink
LockMode::NONE should not set WITH (NOLOCK)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Nov 1, 2020
1 parent cad295a commit 787b7fc
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 12 deletions.
3 changes: 0 additions & 3 deletions lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ class SQLAnywherePlatform extends AbstractPlatform
public function appendLockHint($fromClause, $lockMode)
{
switch (true) {
case $lockMode === LockMode::NONE:
return $fromClause . ' WITH (NOLOCK)';

case $lockMode === LockMode::PESSIMISTIC_READ:
return $fromClause . ' WITH (UPDLOCK)';

Expand Down
3 changes: 0 additions & 3 deletions lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1573,9 +1573,6 @@ public function getForeignKeyReferentialActionSQL($action)
public function appendLockHint($fromClause, $lockMode)
{
switch (true) {
case $lockMode === LockMode::NONE:
return $fromClause . ' WITH (NOLOCK)';

case $lockMode === LockMode::PESSIMISTIC_READ:
return $fromClause . ' WITH (HOLDLOCK, ROWLOCK)';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,14 @@ public function testModifyLimitQueryWithOrderByClause(): void
}

$sql = 'SELECT m0_.NOMBRE AS NOMBRE0, m0_.FECHAINICIO AS FECHAINICIO1, m0_.FECHAFIN AS FECHAFIN2'
. ' FROM MEDICION m0_ WITH (NOLOCK)'
. ' FROM MEDICION m0_'
. ' INNER JOIN ESTUDIO e1_ ON m0_.ESTUDIO_ID = e1_.ID'
. ' INNER JOIN CLIENTE c2_ ON e1_.CLIENTE_ID = c2_.ID'
. ' INNER JOIN USUARIO u3_ ON c2_.ID = u3_.CLIENTE_ID'
. ' WHERE u3_.ID = ? ORDER BY m0_.FECHAINICIO DESC';

$alteredSql = 'SELECT TOP 15 m0_.NOMBRE AS NOMBRE0, m0_.FECHAINICIO AS FECHAINICIO1, m0_.FECHAFIN AS FECHAFIN2'
. ' FROM MEDICION m0_ WITH (NOLOCK)'
. ' FROM MEDICION m0_'
. ' INNER JOIN ESTUDIO e1_ ON m0_.ESTUDIO_ID = e1_.ID'
. ' INNER JOIN CLIENTE c2_ ON e1_.CLIENTE_ID = c2_.ID'
. ' INNER JOIN USUARIO u3_ ON c2_.ID = u3_.CLIENTE_ID'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public static function getLockHints(): iterable
[null, ''],
[false, ''],
[true, ''],
[LockMode::NONE, ' WITH (NOLOCK)'],
[LockMode::NONE, ''],
[LockMode::OPTIMISTIC, ''],
[LockMode::PESSIMISTIC_READ, ' WITH (UPDLOCK)'],
[LockMode::PESSIMISTIC_WRITE, ' WITH (XLOCK)'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ public function testModifyLimitQueryWithExtraLongQuery(): void
public function testModifyLimitQueryWithOrderByClause(): void
{
$sql = 'SELECT m0_.NOMBRE AS NOMBRE0, m0_.FECHAINICIO AS FECHAINICIO1, m0_.FECHAFIN AS FECHAFIN2'
. ' FROM MEDICION m0_ WITH (NOLOCK)'
. ' FROM MEDICION m0_'
. ' INNER JOIN ESTUDIO e1_ ON m0_.ESTUDIO_ID = e1_.ID'
. ' INNER JOIN CLIENTE c2_ ON e1_.CLIENTE_ID = c2_.ID'
. ' INNER JOIN USUARIO u3_ ON c2_.ID = u3_.CLIENTE_ID'
. ' WHERE u3_.ID = ? ORDER BY m0_.FECHAINICIO DESC';

$expected = 'SELECT m0_.NOMBRE AS NOMBRE0, m0_.FECHAINICIO AS FECHAINICIO1, m0_.FECHAFIN AS FECHAFIN2'
. ' FROM MEDICION m0_ WITH (NOLOCK)'
. ' FROM MEDICION m0_'
. ' INNER JOIN ESTUDIO e1_ ON m0_.ESTUDIO_ID = e1_.ID'
. ' INNER JOIN CLIENTE c2_ ON e1_.CLIENTE_ID = c2_.ID'
. ' INNER JOIN USUARIO u3_ ON c2_.ID = u3_.CLIENTE_ID'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function getLockHints(): iterable
{
return [
[null, ''],
[LockMode::NONE, ' WITH (NOLOCK)'],
[LockMode::NONE, ''],
[LockMode::OPTIMISTIC, ''],
[LockMode::PESSIMISTIC_READ, ' WITH (HOLDLOCK, ROWLOCK)'],
[LockMode::PESSIMISTIC_WRITE, ' WITH (UPDLOCK, ROWLOCK)'],
Expand Down

0 comments on commit 787b7fc

Please sign in to comment.