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
60578e93
Unverified
Commit
60578e93
authored
Dec 05, 2018
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bpo/2.9/#3378' into 2.9
parents
3534c6c9
9a2be238
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
15 deletions
+18
-15
SQLAnywherePlatform.php
lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php
+9
-14
SQLAnywherePlatformTest.php
...Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
+9
-1
No files found.
lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php
View file @
60578e93
...
...
@@ -1308,25 +1308,20 @@ SQL
*/
protected
function
doModifyLimitQuery
(
$query
,
$limit
,
$offset
)
{
$limitOffsetClause
=
''
;
$limitOffsetClause
=
$this
->
getTopClauseSQL
(
$limit
,
$offset
)
;
if
(
$limit
>
0
)
{
$limitOffsetClause
=
'TOP '
.
$limit
.
' '
;
return
$limitOffsetClause
===
''
?
$query
:
preg_replace
(
'/^\s*(SELECT\s+(DISTINCT\s+)?)/i'
,
'\1'
.
$limitOffsetClause
.
' '
,
$query
);
}
private
function
getTopClauseSQL
(
?
int
$limit
,
?
int
$offset
)
:
string
{
if
(
$offset
>
0
)
{
if
(
$limit
===
0
)
{
$limitOffsetClause
=
'TOP ALL '
;
}
$limitOffsetClause
.=
'START AT '
.
(
$offset
+
1
)
.
' '
;
return
sprintf
(
'TOP %s START AT %d'
,
$limit
??
'ALL'
,
$offset
+
1
);
}
if
(
$limitOffsetClause
)
{
return
preg_replace
(
'/^\s*(SELECT\s+(DISTINCT\s+)?)/i'
,
'\1'
.
$limitOffsetClause
,
$query
);
}
return
$query
;
return
$limit
===
null
?
''
:
'TOP '
.
$limit
;
}
/**
...
...
tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
View file @
60578e93
...
...
@@ -646,7 +646,7 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
$this
->
platform
->
modifyLimitQuery
(
'SELECT * FROM user'
,
10
,
5
)
);
self
::
assertEquals
(
'SELECT TOP
ALL
START AT 6 * FROM user'
,
'SELECT TOP
0
START AT 6 * FROM user'
,
$this
->
platform
->
modifyLimitQuery
(
'SELECT * FROM user'
,
0
,
5
)
);
}
...
...
@@ -659,6 +659,14 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
);
}
public
function
testModifiesLimitQueryWithoutLimit
()
{
self
::
assertEquals
(
'SELECT TOP ALL START AT 11 n FROM Foo'
,
$this
->
platform
->
modifyLimitQuery
(
'SELECT n FROM Foo'
,
null
,
10
)
);
}
public
function
testPrefersIdentityColumns
()
{
self
::
assertTrue
(
$this
->
platform
->
prefersIdentityColumns
());
...
...
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