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
45e85624
Commit
45e85624
authored
Feb 08, 2014
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #509 from deeky666/fix-sql-anywhere-lock-hints
Fix table lock hints on SQL Anywhere
parents
c4d4c5f2
e107b015
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
29 deletions
+24
-29
SQLAnywherePlatform.php
lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php
+7
-11
SQLAnywherePlatformTest.php
...Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
+17
-18
No files found.
lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php
View file @
45e85624
...
...
@@ -60,26 +60,22 @@ class SQLAnywherePlatform extends AbstractPlatform
/**
* {@inheritdoc}
*
* @throws \InvalidArgumentException
*/
public
function
appendLockHint
(
$fromClause
,
$lockMode
)
{
switch
(
true
)
{
case
$lockMode
===
LockMode
::
NONE
:
$lockClause
=
' WITH (NOLOCK)'
;
break
;
return
$fromClause
.
' WITH (NOLOCK)'
;
case
$lockMode
===
LockMode
::
PESSIMISTIC_READ
:
$lockClause
=
' WITH (UPDLOCK)'
;
break
;
return
$fromClause
.
' WITH (UPDLOCK)'
;
case
$lockMode
===
LockMode
::
PESSIMISTIC_WRITE
:
$lockClause
=
' WITH (XLOCK)'
;
break
;
return
$fromClause
.
' WITH (XLOCK)'
;
default
:
throw
new
\InvalidArgumentException
(
'Invalid lock mode: '
.
$lockMode
)
;
return
$fromClause
;
}
return
$fromClause
.
$lockClause
;
}
/**
...
...
tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
View file @
45e85624
...
...
@@ -220,29 +220,28 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
);
}
public
function
testAppendsLockHints
()
/**
* @dataProvider getLockHints
*/
public
function
testAppendsLockHint
(
$lockMode
,
$lockHint
)
{
$fromClause
=
'SELECT * FROM lock_hints'
;
$fromClause
=
'FROM users'
;
$expectedResult
=
$fromClause
.
$lockHint
;
$this
->
assertEquals
(
$fromClause
.
' WITH (NOLOCK)'
,
$this
->
_platform
->
appendLockHint
(
$fromClause
,
LockMode
::
NONE
)
);
$this
->
assertEquals
(
$fromClause
.
' WITH (UPDLOCK)'
,
$this
->
_platform
->
appendLockHint
(
$fromClause
,
LockMode
::
PESSIMISTIC_READ
)
);
$this
->
assertEquals
(
$fromClause
.
' WITH (XLOCK)'
,
$this
->
_platform
->
appendLockHint
(
$fromClause
,
LockMode
::
PESSIMISTIC_WRITE
)
);
$this
->
assertSame
(
$expectedResult
,
$this
->
_platform
->
appendLockHint
(
$fromClause
,
$lockMode
));
}
public
function
testCannotAppendInvalidLockHint
()
public
function
getLockHints
()
{
$this
->
setExpectedException
(
'\InvalidArgumentException'
);
$this
->
_platform
->
appendLockHint
(
'SELECT * FROM lock_hints'
,
'invalid_lock_mode'
);
return
array
(
array
(
null
,
''
),
array
(
false
,
''
),
array
(
true
,
''
),
array
(
LockMode
::
NONE
,
' WITH (NOLOCK)'
),
array
(
LockMode
::
OPTIMISTIC
,
''
),
array
(
LockMode
::
PESSIMISTIC_READ
,
' WITH (UPDLOCK)'
),
array
(
LockMode
::
PESSIMISTIC_WRITE
,
' WITH (XLOCK)'
),
);
}
public
function
testHasCorrectMaxIdentifierLength
()
...
...
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