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
18f140a9
Commit
18f140a9
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
(cherry picked from commit
69931faa
)
parent
1b62e9f7
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 @
18f140a9
...
@@ -1038,8 +1038,9 @@ abstract class AbstractPlatform
...
@@ -1038,8 +1038,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 @
18f140a9
...
@@ -1012,21 +1012,19 @@ class SQLServerPlatform extends AbstractPlatform
...
@@ -1012,21 +1012,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 @
18f140a9
...
@@ -4,6 +4,7 @@ namespace Doctrine\Tests\DBAL\Platforms;
...
@@ -4,6 +4,7 @@ namespace Doctrine\Tests\DBAL\Platforms;
use
Doctrine\DBAL\Platforms\SQLServer2008Platform
;
use
Doctrine\DBAL\Platforms\SQLServer2008Platform
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\DBAL\LockMode
;
class
SQLServerPlatformTest
extends
AbstractPlatformTestCase
class
SQLServerPlatformTest
extends
AbstractPlatformTestCase
{
{
...
@@ -318,4 +319,28 @@ class SQLServerPlatformTest extends AbstractPlatformTestCase
...
@@ -318,4 +319,28 @@ class SQLServerPlatformTest extends AbstractPlatformTestCase
'ALTER TABLE [quoted] ADD CONSTRAINT FK_WITH_INTENDED_QUOTATION FOREIGN KEY ([create], foo, [bar]) REFERENCES [foo-bar] ([create], bar, [foo-bar])'
,
'ALTER TABLE [quoted] ADD CONSTRAINT FK_WITH_INTENDED_QUOTATION FOREIGN KEY ([create], foo, [bar]) REFERENCES [foo-bar] ([create], bar, [foo-bar])'
,
);
);
}
}
/**
* @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