Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
69931faa
Commit
69931faa
authored
Jan 14, 2014
by
Steve Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix evaluation of NOLOCK table hint on SQL Server
parent
2790ee79
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
15 deletions
+39
-15
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+3
-2
SQLServerPlatform.php
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
+11
-13
SQLServerPlatformTest.php
...s/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php
+25
-0
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
69931faa
...
...
@@ -1110,8 +1110,9 @@ abstract class AbstractPlatform
/**
* Honors that some SQL vendors such as MsSql use table hints for locking instead of the ANSI SQL FOR UPDATE specification.
*
* @param string $fromClause
* @param integer $lockMode
* @param string $fromClause The FROM clause to append the hint for the given lock mode to.
* @param integer|null $lockMode One of the Doctrine\DBAL\LockMode::* constants. If null is given, nothing will
* be appended to the FROM clause.
*
* @return string
*/
...
...
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
View file @
69931faa
...
...
@@ -1347,21 +1347,19 @@ class SQLServerPlatform extends AbstractPlatform
*/
public
function
appendLockHint
(
$fromClause
,
$lockMode
)
{
switch
(
$lockMod
e
)
{
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
;
switch
(
tru
e
)
{
case
LockMode
::
NONE
===
$lockMode
:
return
$fromClause
.
' WITH (NOLOCK)'
;
case
LockMode
::
PESSIMISTIC_READ
===
$lockMode
:
return
$fromClause
.
' WITH (HOLDLOCK, ROWLOCK)'
;
case
LockMode
::
PESSIMISTIC_WRITE
===
$lockMode
:
return
$fromClause
.
' WITH (UPDLOCK, ROWLOCK)'
;
default
:
$lockClause
=
''
;
return
$fromClause
;
}
return
$fromClause
.
$lockClause
;
}
/**
...
...
tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php
View file @
69931faa
...
...
@@ -2,6 +2,7 @@
namespace
Doctrine\Tests\DBAL\Platforms
;
use
Doctrine\DBAL\LockMode
;
use
Doctrine\DBAL\Platforms\SQLServerPlatform
;
class
SQLServerPlatformTest
extends
AbstractSQLServerPlatformTestCase
...
...
@@ -11,4 +12,28 @@ class SQLServerPlatformTest extends AbstractSQLServerPlatformTestCase
return
new
SQLServerPlatform
;
}
/**
* @group DDC-2310
* @dataProvider getLockHints
*/
public
function
testAppendsLockHint
(
$lockMode
,
$lockHint
)
{
$fromClause
=
'FROM users'
;
$expectedResult
=
$fromClause
.
$lockHint
;
$this
->
assertSame
(
$expectedResult
,
$this
->
_platform
->
appendLockHint
(
$fromClause
,
$lockMode
));
}
public
function
getLockHints
()
{
return
array
(
array
(
null
,
''
),
array
(
false
,
''
),
array
(
true
,
''
),
array
(
LockMode
::
NONE
,
' WITH (NOLOCK)'
),
array
(
LockMode
::
OPTIMISTIC
,
''
),
array
(
LockMode
::
PESSIMISTIC_READ
,
' WITH (HOLDLOCK, ROWLOCK)'
),
array
(
LockMode
::
PESSIMISTIC_WRITE
,
' WITH (UPDLOCK, ROWLOCK)'
),
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment