Permalink
Browse files

fix SQLServerPlatform locking hints

  • Loading branch information...
1 parent 1926921 commit 6af7845cc3779176ec7e111200fe69654179eaf8 @deeky666 deeky666 committed Jan 25, 2013
Showing with 9 additions and 5 deletions.
  1. +9 −5 lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
@@ -34,6 +34,7 @@
* @author Roman Borschel <roman@code-factory.org>
* @author Jonathan H. Wage <jonwage@gmail.com>
* @author Benjamin Eberlei <kontakt@beberlei.de>
+ * @author Steve Müller <st.mueller@dzh-online.de>
*/
class SQLServerPlatform extends AbstractPlatform
{
@@ -845,16 +846,19 @@ public function rollbackSavePoint($savepoint)
*/
public function appendLockHint($fromClause, $lockMode)
{
- // @todo correct
+ $tableHint = '';
+
+ if ($lockMode == \Doctrine\DBAL\LockMode::NONE) {
+ $tableHint = ' WITH (READUNCOMMITTED)'; // equivalent to NOLOCK
+ }
if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) {
- return $fromClause . ' WITH (tablockx)';
+ $tableHint = ' WITH (READCOMMITTED)';
}
-
if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE) {
- return $fromClause . ' WITH (tablockx)';
+ $tableHint = ' WITH (SERIALIZABLE)'; // equivalent to HOLDLOCK
}
- return $fromClause;
+ return $fromClause . $tableHint;
}
/**

1 comment on commit 6af7845

This change highlighted a bug in the ORM SqlWalker -- #DDC-2310

Please sign in to comment.