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

[10.x] Fix sql server paging problems #47763

Merged
merged 1 commit into from Jul 17, 2023

Conversation

joelharkes
Copy link
Contributor

@joelharkes joelharkes commented Jul 17, 2023

I fixed it long ago in this PR: #39863

But now the problem is back since this PR: #44937 (comment)

Problem

  • Page 1 has no offset and there is no explicit filtering
  • page 2: has offset and thus has explicit filtering

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.

* @param \Illuminate\Database\Query\Builder $query
* @return array
*/
protected function sortBindingsForSubqueryOrderBy($query)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused and not cleaned up in PR: #44937

* @param \Illuminate\Database\Query\Builder $query
* @return string
*/
protected function compileRowConstraint($query)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused and not cleaned up in PR: #44937

@taylorotwell taylorotwell merged commit 53b02b3 into laravel:10.x Jul 17, 2023
16 of 17 checks passed
@taylorotwell
Copy link
Member

Thank you!

@joelharkes
Copy link
Contributor Author

@joelharkes
Copy link
Contributor Author

this might implicitly break distinct combined with limit statement.

@joelharkes
Copy link
Contributor Author

joelharkes commented Jul 17, 2023

dunhamjared added a commit to dunhamjared/laravel-framework that referenced this pull request Jul 17, 2023
taylorotwell pushed a commit that referenced this pull request Jul 24, 2023
* Revert "Fix sql server paging problems (#47763)"

This reverts commit 53b02b3.

* Removed unused functions

* Re-enabled sql server workflow
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.

None yet

2 participants