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
9cb36d01
Commit
9cb36d01
authored
Jul 08, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #4212: MSSQL query builder should not generate the `ORDER BY` clause when it is not needed
parent
474e664c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
29 deletions
+10
-29
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
QueryBuilder.php
framework/db/mssql/QueryBuilder.php
+9
-29
No files found.
framework/CHANGELOG.md
View file @
9cb36d01
...
...
@@ -245,6 +245,7 @@ Yii Framework 2 Change Log
-
Bug #2862: Using
`DbCache`
while enabling schema caching may cause infinite loops (qiangxue)
-
Bug #3052: Fixed the issue that cache dependency data is not reused when
`reusable`
is set true (qiangxue)
-
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: 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 @
9cb36d01
...
...
@@ -39,15 +39,6 @@ class QueryBuilder extends \yii\db\QueryBuilder
Schema
::
TYPE_MONEY
=>
'decimal(19,4)'
,
];
// public function update($table, $columns, $condition, &$params)
// {
// return '';
// }
// public function delete($table, $condition, &$params)
// {
// return '';
// }
/**
* @param integer $limit
...
...
@@ -71,11 +62,6 @@ class QueryBuilder extends \yii\db\QueryBuilder
}
}
// public function resetSequence($table, $value = null)
// {
// return '';
// }
/**
* Builds a SQL statement for renaming a DB table.
* @param string $table the table to be renamed. The name will be properly quoted by the method.
...
...
@@ -143,25 +129,19 @@ class QueryBuilder extends \yii\db\QueryBuilder
/**
* @inheritdoc
*/
public
function
buildOrderBy
(
$columns
)
{
if
(
empty
(
$columns
))
{
// hack so LIMIT will work if no ORDER BY is specified
return
'ORDER BY (SELECT NULL)'
;
}
else
{
return
parent
::
buildOrderBy
(
$columns
);
}
}
/**
* @inheritdoc
*/
public
function
build
(
$query
,
$params
=
[])
{
$query
->
prepareBuild
(
$this
);
$params
=
empty
(
$params
)
?
$query
->
params
:
array_merge
(
$params
,
$query
->
params
);
if
(
empty
(
$query
->
orderBy
)
&&
(
$this
->
hasLimit
(
$query
->
limit
)
||
$this
->
hasOffset
(
$query
->
offset
))
&&
$this
->
isOldMssql
())
{
// hack so LIMIT will work because ROW_NUMBER requires an ORDER BY clause
$orderBy
=
'ORDER BY (SELECT NULL)'
;
}
else
{
$orderBy
=
$this
->
buildOrderBy
(
$query
->
orderBy
);
}
$clauses
=
[
$this
->
buildSelect
(
$query
->
select
,
$params
,
$query
->
distinct
,
$query
->
selectOption
),
$this
->
buildFrom
(
$query
->
from
,
$params
),
...
...
@@ -169,7 +149,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
),
];
...
...
@@ -189,7 +169,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
* Applies limit and offset to SQL query
*
* @param string $sql SQL query
* @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
*/
private
function
applyLimitAndOffset
(
$sql
,
$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