Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
PSDI Army
yii2
Commits
3704b919
Commit
3704b919
authored
Aug 13, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #4697: MSSQL query builder does not work for newer MSSQL versions when…
Fixes #4697: MSSQL query builder does not work for newer MSSQL versions when LIMIT is used without ORDER BY
parent
9b1ab7cd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
QueryBuilder.php
framework/db/mssql/QueryBuilder.php
+8
-2
No files found.
framework/CHANGELOG.md
View file @
3704b919
...
...
@@ -314,6 +314,7 @@ Yii Framework 2 Change Log
-
Bug #3691: Fixed the issue that
`CookieCollection::has`
always returns false for cookies from browser (sonicgd)
-
Bug #4212: MSSQL query builder should not generate the
`ORDER BY`
clause when it is not needed (qiangxue)
-
Bug #4232:
`TableSchema::sequenceName`
for PostgreSQL should remove the enclosing quotes (katzz0, qiangxue)
-
Bug #4697: MSSQL query builder does not work for newer MSSQL versions when LIMIT is used without ORDER BY (qiangxue)
-
Bug: Fixed
`Call to a member function registerAssetFiles() on a non-object`
in case of wrong
`sourcePath`
for an asset bundle (samdark)
-
Bug: Fixed incorrect event name for
`yii\jui\Spinner`
(samdark)
-
Bug: Json::encode() did not handle objects that implement JsonSerializable interface correctly (cebe)
...
...
framework/db/mssql/QueryBuilder.php
View file @
3704b919
...
...
@@ -135,6 +135,12 @@ class QueryBuilder extends \yii\db\QueryBuilder
$params
=
empty
(
$params
)
?
$query
->
params
:
array_merge
(
$params
,
$query
->
params
);
$orderBy
=
$this
->
buildOrderBy
(
$query
->
orderBy
);
if
(
$orderBy
===
''
&&
(
$this
->
hasOffset
(
$query
->
offset
)
||
$this
->
hasLimit
(
$query
->
limit
))
&&
!
$this
->
isOldMssql
())
{
// ORDER BY clause is required when FETCH and OFFSET are in the SQL
$orderBy
=
'ORDER BY (SELECT NULL)'
;
}
$clauses
=
[
$this
->
buildSelect
(
$query
->
select
,
$params
,
$query
->
distinct
,
$query
->
selectOption
),
$this
->
buildFrom
(
$query
->
from
,
$params
),
...
...
@@ -142,7 +148,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
$this
->
buildWhere
(
$query
->
where
,
$params
),
$this
->
buildGroupBy
(
$query
->
groupBy
),
$this
->
buildHaving
(
$query
->
having
,
$params
),
$
this
->
buildOrderBy
(
$query
->
orderBy
)
,
$
orderBy
,
$this
->
isOldMssql
()
?
''
:
$this
->
buildLimit
(
$query
->
limit
,
$query
->
offset
),
];
...
...
@@ -181,7 +187,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
* @param string $sql SQL query
* @param integer $limit
* @param integer $offset
* @param \yii\db\
Active
Query $query the [[Query]] object from which the SQL statement generated
* @param \yii\db\Query $query the [[Query]] object from which the SQL statement generated
* @return string resulting SQL query
*/
private
function
rewriteLimitOffsetSql
(
$sql
,
$limit
,
$offset
,
$query
)
...
...
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