Skip to content

[5.9] EachById #28065

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

Merged
merged 1 commit into from
Apr 1, 2019
Merged

[5.9] EachById #28065

merged 1 commit into from
Apr 1, 2019

Conversation

halaei
Copy link
Contributor

@halaei halaei commented Mar 29, 2019

Reopening #28024 (targetting 5.8) for laravel 5.9. This is also a refactor for chunkById() and actually reduces the total lines of codes (except for tests) while adding a new feature.

New Feature:
eachById() is a more efficient alternative to each(), just like chunkById() is to chunk(). The runtime complexity is not quadratic and it works fine for read-write scans as well.

Changes:

  • chunkById() functions in Query\Builder and Eloquent\Builder was mostly duplicate, so I removed them and move their main parts to BuildsQueries trait.
  • The different parts of chunkById() in the 2 classes are now moved to defaultKeyName() function.
  • The default value for $column in Query\Builder::chunkById() was 'id'. Now it is null.
  • The description of chunkById() is changed from "Chunk the results of a query by comparing numeric IDs." to "Chunk the results of a query by comparing IDs." because it handles non-numeric ids as well.

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