[8.x] Columns in the order by list must be unique #37505
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In my application I have this kind of code:
Somewhere else I have :
Model::scopes(['parents', 'enabled'])->first()
The SQL produced by this query is:
select * from models where parent_id is null and is_enabled = 1 order by position asc, position asc
This works in MySql however SQLServer complain saying:
A column has been specified more than once in the order by list. Columns in the order by list must be unique
You might say "Then just remove one orderBy() in either scope" however both are used independently.
I saw it happened to Nova see : laravel/nova-issues#1621
What I suggest is to make sure this cannot happen, let me know if I need to change anything!