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
9a2be238
Unverified
Commit
9a2be238
authored
Dec 04, 2018
by
Steve Müller
Committed by
Sergei Morozov
Dec 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix query limit values "0" and "null" on SQL Anywhere
parent
9d382e69
Changes
2
Hide 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 @
9a2be238
...
@@ -1308,25 +1308,20 @@ SQL
...
@@ -1308,25 +1308,20 @@ SQL
*/
*/
protected
function
doModifyLimitQuery
(
$query
,
$limit
,
$offset
)
protected
function
doModifyLimitQuery
(
$query
,
$limit
,
$offset
)
{
{
$limitOffsetClause
=
''
;
$limitOffsetClause
=
$this
->
getTopClauseSQL
(
$limit
,
$offset
)
;
if
(
$limit
>
0
)
{
return
$limitOffsetClause
===
''
$limitOffsetClause
=
'TOP '
.
$limit
.
' '
;
?
$query
}
:
preg_replace
(
'/^\s*(SELECT\s+(DISTINCT\s+)?)/i'
,
'\1'
.
$limitOffsetClause
.
' '
,
$query
);
}
private
function
getTopClauseSQL
(
?
int
$limit
,
?
int
$offset
)
:
string
{
if
(
$offset
>
0
)
{
if
(
$offset
>
0
)
{
if
(
$limit
===
0
)
{
return
sprintf
(
'TOP %s START AT %d'
,
$limit
??
'ALL'
,
$offset
+
1
);
$limitOffsetClause
=
'TOP ALL '
;
}
$limitOffsetClause
.=
'START AT '
.
(
$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 @
9a2be238
...
@@ -646,7 +646,7 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
...
@@ -646,7 +646,7 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
$this
->
platform
->
modifyLimitQuery
(
'SELECT * FROM user'
,
10
,
5
)
$this
->
platform
->
modifyLimitQuery
(
'SELECT * FROM user'
,
10
,
5
)
);
);
self
::
assertEquals
(
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
)
$this
->
platform
->
modifyLimitQuery
(
'SELECT * FROM user'
,
0
,
5
)
);
);
}
}
...
@@ -659,6 +659,14 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
...
@@ -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
()
public
function
testPrefersIdentityColumns
()
{
{
self
::
assertTrue
(
$this
->
platform
->
prefersIdentityColumns
());
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