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

Select All Matching causes sql error for SQL Server with actions #1621

Closed
FrittenKeeZ opened this issue May 23, 2019 · 2 comments
Closed

Select All Matching causes sql error for SQL Server with actions #1621

FrittenKeeZ opened this issue May 23, 2019 · 2 comments
Labels
bug Verified bug by the Nova team
Milestone

Comments

@FrittenKeeZ
Copy link

  • Laravel Version: 5.8.17
  • Nova Version: 2.0.5
  • PHP Version: 7.2
  • Operating System and Version: Ubuntu 16.04.5 LTS
  • Browser type and version: Chrome 74

Description:

Using "Select All Matching" and running an action, will result in a query where id is sorted twice. Looking at the queries from Telescope I see the following:

SQL Server

select top 200 * from [jobs] where [jobs].[deleted_at] is null order by [id] desc, [id] desc

MySQL

select * from `jobs` where `jobs`.`deleted_at` is null order by `jobs`.`id` desc, `id` desc limit 200 offset 0

This works fine on MySQL but throws an exception for SQL Server:

SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]A column has been specified more than once in the order by list. Columns in the order by list must be unique. (SQL: select top 200 * from [jobs] where [jobs].[deleted_at] is null order by [id] desc, [id] desc)

Backtracing reveal that it's caused by using latest() in Laravel\Nova\Http\Requests\ActionRequest::chunks().

There's also an error in Laravel\Nova\PerformsQueries::applyOrderings() on line 143, where empty($query->orders) should be empty($query->getQuery()->orders).

Steps To Reproduce:

  1. Create any action and apply it to a resource.
  2. Use "Select All Matching" and run the action.
  3. See that the sql query is generated with the same ordering twice.
@knutle
Copy link

knutle commented Jun 25, 2019

I am also having this issue

@jbrooksuk jbrooksuk changed the title [Bug] Select All Matching causes sql error for SQL Server with actions Select All Matching causes sql error for SQL Server with actions Jul 31, 2019
@jbrooksuk jbrooksuk added the bug Verified bug by the Nova team label Jul 31, 2019
@jbrooksuk jbrooksuk added this to the v2.0 milestone Aug 1, 2019
Javdu10 added a commit to Javdu10/framework that referenced this issue May 27, 2021
MySql is ok with it, but SqlServer error out.
See a similar issue here: laravel/nova-issues#1621
Javdu10 added a commit to Javdu10/framework that referenced this issue May 27, 2021
MySql is ok with it, but SqlServer error out.
See a similar issue here: laravel/nova-issues#1621
taylorotwell added a commit to laravel/framework that referenced this issue Jun 1, 2021
* Columns in the order by list must be unique

MySql is ok with it, but SqlServer error out.
See a similar issue here: laravel/nova-issues#1621

* override with next call

* Update Builder.php

Co-authored-by: Taylor Otwell <[email protected]>
taylorotwell added a commit to illuminate/database that referenced this issue Jun 1, 2021
* Columns in the order by list must be unique

MySql is ok with it, but SqlServer error out.
See a similar issue here: laravel/nova-issues#1621

* override with next call

* Update Builder.php

Co-authored-by: Taylor Otwell <[email protected]>
taylorotwell added a commit to laravel/framework that referenced this issue Jun 4, 2021
* Columns in the order by list must be unique

MySql is ok with it, but SqlServer error out.
See a similar issue here: laravel/nova-issues#1621

* override with next call

* Update Builder.php

* fix: "undefined index: column" from #37581

* add a regression test

Co-authored-by: Taylor Otwell <[email protected]>
taylorotwell added a commit to illuminate/database that referenced this issue Jun 4, 2021
* Columns in the order by list must be unique

MySql is ok with it, but SqlServer error out.
See a similar issue here: laravel/nova-issues#1621

* override with next call

* Update Builder.php

* fix: "undefined index: column" from #37581

* add a regression test

Co-authored-by: Taylor Otwell <[email protected]>
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Verified bug by the Nova team
Projects
None yet
Development

No branches or pull requests

3 participants