Skip to content

Commit 7d5777c

Browse files
committedNov 11, 2015
Merge branch 'hotfix/v5.11.14'
2 parents ca17c06 + a5e464d commit 7d5777c

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed
 

‎change-log.md

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
##Change Log
1010

11+
###v5.11.14
12+
- Sort by a multi-line 'select as' query. PR #245
13+
1114
###v5.11.13
1215
- Allow fractal v0.12 and up. Fix #237.
1316

‎src/yajra/Datatables/Engines/BaseEngine.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,10 @@ protected function getColumnName($column)
251251
*/
252252
public function extractColumnName($str)
253253
{
254-
preg_match('#^(\S*?)\s+as\s+(\S*?)$#si', $str, $matches);
254+
$matches = explode(' as ', Str::lower($str));
255255

256256
if ( ! empty($matches)) {
257-
return $matches[2];
257+
return array_pop($matches);
258258
} elseif (strpos($str, '.')) {
259259
$array = explode('.', $str);
260260

‎src/yajra/Datatables/Engines/QueryBuilderEngine.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,17 @@ public function filtering()
9595
function ($query) {
9696
$keyword = $this->setupKeyword($this->request->keyword());
9797
foreach ($this->request->searchableColumnIndex() as $index) {
98-
$column = $this->setupColumnName($index);
98+
$columnName = $this->setupColumnName($index);
9999

100-
if (isset($this->columnDef['filter'][$column])) {
101-
$method = Helper::getOrMethod($this->columnDef['filter'][$column]['method']);
102-
$parameters = $this->columnDef['filter'][$column]['parameters'];
100+
if (isset($this->columnDef['filter'][$columnName])) {
101+
$method = Helper::getOrMethod($this->columnDef['filter'][$columnName]['method']);
102+
$parameters = $this->columnDef['filter'][$columnName]['parameters'];
103103
$this->compileColumnQuery(
104-
$this->getQueryBuilder($query), $method, $parameters, $column, $keyword
104+
$this->getQueryBuilder($query), $method, $parameters, $columnName, $keyword
105105
);
106106
} else {
107-
$column = $this->prefixColumn($column);
108-
$this->compileGlobalSearch($this->getQueryBuilder($query), $column, $keyword);
107+
$columnName = $this->prefixColumn($columnName);
108+
$this->compileGlobalSearch($this->getQueryBuilder($query), $columnName, $keyword);
109109
}
110110

111111
$this->isFilterApplied = true;

0 commit comments

Comments
 (0)
Failed to load comments.