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 @@
namespace Doctrine\DBAL\Platforms;
use Doctrine\DBAL\LockMode;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
......@@ -872,16 +873,21 @@ class SQLServerPlatform extends AbstractPlatform
*/
public function appendLockHint($fromClause, $lockMode)
{
// @todo correct
if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) {
return $fromClause . ' WITH (tablockx)';
}
if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE) {
return $fromClause . ' WITH (tablockx)';
}
return $fromClause;
switch ($lockMode) {
case LockMode::NONE:
$lockClause = ' WITH (NOLOCK)';
break;
case LockMode::PESSIMISTIC_READ:
$lockClause = ' WITH (HOLDLOCK, ROWLOCK)';
break;
case LockMode::PESSIMISTIC_WRITE:
$lockClause = ' WITH (UPDLOCK, ROWLOCK)';
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