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
Hide 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
...
@@ -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.
* 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 string $fromClause The FROM clause to append the hint for the given lock mode to.
* @param integer $lockMode
* @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
* @return string
*/
*/
...
...
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
View file @
69931faa
...
@@ -1347,21 +1347,19 @@ class SQLServerPlatform extends AbstractPlatform
...
@@ -1347,21 +1347,19 @@ class SQLServerPlatform extends AbstractPlatform
*/
*/
public
function
appendLockHint
(
$fromClause
,
$lockMode
)
public
function
appendLockHint
(
$fromClause
,
$lockMode
)
{
{
switch
(
$lockMod
e
)
{
switch
(
tru
e
)
{
case
LockMode
::
NONE
:
case
LockMode
::
NONE
===
$lockMode
:
$lockClause
=
' WITH (NOLOCK)'
;
return
$fromClause
.
' WITH (NOLOCK)'
;
break
;
case
LockMode
::
PESSIMISTIC_READ
:
case
LockMode
::
PESSIMISTIC_READ
===
$lockMode
:
$lockClause
=
' WITH (HOLDLOCK, ROWLOCK)'
;
return
$fromClause
.
' WITH (HOLDLOCK, ROWLOCK)'
;
break
;
case
LockMode
::
PESSIMISTIC_WRITE
:
case
LockMode
::
PESSIMISTIC_WRITE
===
$lockMode
:
$lockClause
=
' WITH (UPDLOCK, ROWLOCK)'
;
return
$fromClause
.
' WITH (UPDLOCK, ROWLOCK)'
;
break
;
default
:
default
:
$lockClause
=
''
;
return
$fromClause
;
}
}
return
$fromClause
.
$lockClause
;
}
}
/**
/**
...
...
tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php
View file @
69931faa
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
Doctrine\Tests\DBAL\Platforms
;
namespace
Doctrine\Tests\DBAL\Platforms
;
use
Doctrine\DBAL\LockMode
;
use
Doctrine\DBAL\Platforms\SQLServerPlatform
;
use
Doctrine\DBAL\Platforms\SQLServerPlatform
;
class
SQLServerPlatformTest
extends
AbstractSQLServerPlatformTestCase
class
SQLServerPlatformTest
extends
AbstractSQLServerPlatformTestCase
...
@@ -11,4 +12,28 @@ class SQLServerPlatformTest extends AbstractSQLServerPlatformTestCase
...
@@ -11,4 +12,28 @@ class SQLServerPlatformTest extends AbstractSQLServerPlatformTestCase
return
new
SQLServerPlatform
;
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