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

Change formatting of relational column to allow proper sorting. #757

Closed
wants to merge 1 commit into from

Conversation

korki696
Copy link

@korki696 korki696 commented May 4, 2022

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests and did you add any new tests needed for your feature?
  2. Did you update all templates (if applicable)?
  3. Did you add the relevant documentation (if applicable)?
  4. Did you test locally to make sure your feature works as intended?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

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.

@rappasoft
Copy link
Owner

We need a way for this to both work in MySQL and postgres. Personally, I can't replicate this though.

@korki696
Copy link
Author

korki696 commented May 4, 2022

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?

@rappasoft
Copy link
Owner

Should we do a conditional and just set it differently for the different drivers?

@damiandejong
Copy link

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.

damiandejong@ad96a80

@stale
Copy link

stale bot commented Jun 23, 2022

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.

@stale stale bot added the wontfix This will not be worked on label Jun 23, 2022
@stale stale bot closed this Jul 1, 2022
@rappasoft rappasoft reopened this Jul 2, 2022
@stale stale bot removed the wontfix This will not be worked on label Jul 2, 2022
@stale
Copy link

stale bot commented Aug 1, 2022

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.

@stale stale bot added the wontfix This will not be worked on label Aug 1, 2022
@mitulgolakiya
Copy link

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 " instead of `, then sorting is stopped with MySQL.

@stale stale bot removed the wontfix This will not be worked on label Aug 5, 2022
@vishalinfyom
Copy link

Yes, facing same issue.

after upgrading to latest version in MySQL, sorting is not working.

@stale
Copy link

stale bot commented Sep 8, 2022

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.

@stale stale bot added the wontfix This will not be worked on label Sep 8, 2022
@stale stale bot closed this Sep 15, 2022
@rappasoft rappasoft reopened this Sep 15, 2022
@stale stale bot removed the wontfix This will not be worked on label Sep 15, 2022
@bskiefer
Copy link

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();
    }

@stale
Copy link

stale bot commented Oct 16, 2022

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.

@stale stale bot added the wontfix This will not be worked on label Oct 16, 2022
@stale stale bot closed this Oct 23, 2022
@rappasoft rappasoft reopened this Oct 23, 2022
@stale stale bot removed the wontfix This will not be worked on label Oct 23, 2022
@stale
Copy link

stale bot commented Nov 22, 2022

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.

@stale stale bot added the wontfix This will not be worked on label Nov 22, 2022
@stale stale bot closed this Nov 29, 2022
@rappasoft rappasoft reopened this Dec 4, 2022
@stale stale bot removed the wontfix This will not be worked on label Dec 4, 2022
@rappasoft
Copy link
Owner

Closing this in favor of this fix: damiandejong@ad96a80

@rappasoft rappasoft closed this Dec 21, 2022
rappasoft added a commit that referenced this pull request Dec 21, 2022
@rappasoft rappasoft mentioned this pull request Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants