Commit 02ea5f03 authored by Guilherme Blanco's avatar Guilherme Blanco

Merge pull request #257 from deeky666/fix-sqlserverplatform-lockhints

fix SQLServerPlatform locking hints
parents 68a4633e c9b1dc1b
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
namespace Doctrine\DBAL\Platforms; namespace Doctrine\DBAL\Platforms;
use Doctrine\DBAL\LockMode;
use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\ForeignKeyConstraint;
...@@ -872,16 +873,21 @@ class SQLServerPlatform extends AbstractPlatform ...@@ -872,16 +873,21 @@ class SQLServerPlatform extends AbstractPlatform
*/ */
public function appendLockHint($fromClause, $lockMode) public function appendLockHint($fromClause, $lockMode)
{ {
// @todo correct switch ($lockMode) {
if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) { case LockMode::NONE:
return $fromClause . ' WITH (tablockx)'; $lockClause = ' WITH (NOLOCK)';
} break;
case LockMode::PESSIMISTIC_READ:
if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE) { $lockClause = ' WITH (HOLDLOCK, ROWLOCK)';
return $fromClause . ' WITH (tablockx)'; break;
} case LockMode::PESSIMISTIC_WRITE:
$lockClause = ' WITH (UPDLOCK, ROWLOCK)';
return $fromClause; break;
default:
$lockClause = '';
}
return $fromClause . $lockClause;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment