Skip to content

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