[10.x] Fix sql server paging problems#47763
Merged
taylorotwell merged 1 commit intolaravel:10.xfrom Jul 17, 2023
Merged
Conversation
joelharkes
commented
Jul 17, 2023
| * @param \Illuminate\Database\Query\Builder $query | ||
| * @return array | ||
| */ | ||
| protected function sortBindingsForSubqueryOrderBy($query) |
| * @param \Illuminate\Database\Query\Builder $query | ||
| * @return string | ||
| */ | ||
| protected function compileRowConstraint($query) |
Member
|
Thank you! |
Contributor
Author
|
wait it seemed sql server was still throwing errors :D |
Contributor
Author
|
this might implicitly break distinct combined with limit statement. |
Contributor
Author
|
here is more context on the ordering issue: https://stackoverflow.com/a/20050403/1275832 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I fixed it long ago in this PR: #39863
But now the problem is back since this PR: #44937 (comment)
Problem
if column 0 is not identical to the SQL server fragmentation/page order (which is not identical to the primary key order). It can be that items on page 1 are also shown on later pages and visa versa, items are missing that should be on page 1.
Solution
To also page when there is a limit set, OR an offset set, this way we guarentuee items are not mistakenly sorted wrongly.
alternative solutions
Always add select 0 to make sure order is always followed, even when there is no limit and offset. Although this is less of na issue.
Breaking changes
I removed 2 protected methods that were no longer used since #44937.
Since the subset using sql server drivers is very small there is a very, very small change any developer had these methods overwritten or used. even if someone had overwritten them it wouldn't change a thing. and if someone used them, they were probably not valid anymore anyways.