-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
Change formatting of relational column to allow proper sorting. #757
Conversation
We need a way for this to both work in MySQL and postgres. Personally, I can't replicate this though. |
I am running on MySQL8 and even just a raw query will only work with backquotes. I don't have a Postgres spun up or am to familiar with it. Are you able to sort a relational column on MySQL with the current implementation? |
Should we do a conditional and just set it differently for the different drivers? |
Dear Anthony, This pull request deals with the same problem I described in my reply to #734. As this pull request is just rewinding the changes in #734, I agree the query should be defined conditionally by the database driver being used. Therefore, I made a change that uses the Laravel logic for query grammar. Maybe there is a simpeler approach, but I believe in this way, the proper alias/column is used and the quotes are set depending on the database driver. I haven't been able to test it for Postgresql, but for MySQL it works. I wanted to create a pull request for it, but since this one is still open, I thought it might be better to put it here first. Please let me know if I need to create a pull request anyway. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Facing the same issue. I had a column with relationship sorting. Everything was working fine for version 2.1.1. After upgrading to 2.2.0+, none of the related columns are working. Seems like the problem is when order by column name is replaced with double quotes |
Yes, facing same issue. after upgrading to latest version in MySQL, sorting is not working. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I was able to resolve by adding this method to my controllers: public function getRows()
{
$this->baseQuery();
$query = $this->getBuilder()->getQuery();
$orders = $query->orders;
$query->orders = [];
foreach ($orders as $order) {
$query->orders[] = [
'type' => 'Raw',
'sql' => str_replace('"', '`', $order['sql'])
];
}
$this->getBuilder()->setQuery($query);
return $this->executeQuery();
} |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Closing this in favor of this fix: damiandejong@ad96a80 |
All Submissions:
New Feature Submissions:
Changes to Core Features:
When sorting a relational column, the table wouldn't actually sort. Changing the query to use a backquote (`) instead of a double quote (") seems to fix this.