Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle HAVING clause which does not accept alias in filter queries #1028

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Grid/Source/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ protected function getFieldName($column, $withAlias = false)

return "$functionWithParameters as $alias";
}
// To handle query from filter with necessary HAVING clause which does not accept alias
if (!$withAlias && $hasHaving) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable $hasHaving comes from nowhere.

I guess that it should be $hasHavingClause given as parameter of the function ?

return $functionWithParameters;
}

return $alias;
}
Expand Down Expand Up @@ -437,7 +441,7 @@ public function execute($columns, $page = 0, $limit = 0, $maxResults = null, $gr

$columnForFilter = (!$column instanceof JoinColumn) ? $column : $columnsById[$filter->getColumnName()];

$fieldName = $this->getFieldName($columnForFilter, false);
$fieldName = $this->getFieldName($columnForFilter, false, $hasHavingClause);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you add a parameter to this function, you should change its signature wich is actually

protected function getFieldName($column, $withAlias = false)

$bindIndexPlaceholder = "?$bindIndex";

if( in_array($filter->getOperator(), array(Column::OPERATOR_LIKE,Column::OPERATOR_RLIKE,Column::OPERATOR_LLIKE,Column::OPERATOR_NLIKE,))){
Expand Down