Skip to content

Comments

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

Merged
taylorotwell merged 1 commit intolaravel:10.xfrom
joelharkes:fix_sql_server
Jul 17, 2023
Merged

[10.x] Fix sql server paging problems#47763
taylorotwell merged 1 commit intolaravel:10.xfrom
joelharkes:fix_sql_server

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
Copy link
Member

Thank you!

@joelharkes
Copy link
Contributor Author

@joelharkes
Copy link
Contributor Author

this might implicitly break distinct combined with limit statement.

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.

2 participants