Skip to content

Remove Eloquent\Builder::chunkById() already having the correct id field in Laravel #2569

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
Aug 23, 2023

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Aug 22, 2023

This method was necessary to rename the key name to _id (MongoDB's default). chunkById was refactored in laravel/framework#28065 to allow custom key name.

Reverts #1317

@codecov-commenter
Copy link

codecov-commenter commented Aug 22, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.02% ⚠️

Comparison is base (49ec43c) 90.59% compared to head (348f0c1) 90.58%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2569      +/-   ##
============================================
- Coverage     90.59%   90.58%   -0.02%     
+ Complexity      749      748       -1     
============================================
  Files            34       34              
  Lines          1787     1785       -2     
============================================
- Hits           1619     1617       -2     
  Misses          168      168              
Files Changed Coverage Δ
src/Eloquent/Builder.php 85.50% <ø> (-0.41%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

$count += count($items);
$names = [];
User::chunkById(2, function (EloquentCollection $items) use (&$names) {
$names = array_merge($names, $items->pluck('name')->all());
Copy link
Member

Choose a reason for hiding this comment

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

I noted your response in GromNaN/laravel-mongodb#25 (comment).

Not sure why I thought + concatenated instead of overwrote for numeric indexes. I certainly confused it with array_merge(), which is what we do need to use here 👍

*/
public function chunkById($count, callable $callback, $column = '_id', $alias = null)
{
return parent::chunkById($count, $callback, $column, $alias);
Copy link
Member

Choose a reason for hiding this comment

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

Noted your response in GromNaN/laravel-mongodb#25 (comment).

I missed that the meaningful change here was removing the _id parameter default value, since Laravel now consults the configured primary key (laravel/framework#28065).

@alcaeus alcaeus merged commit b484288 into mongodb:master Aug 23, 2023
@GromNaN GromNaN deleted the clean-chunkById branch August 23, 2023 09:44
@GromNaN GromNaN added this to the 4.0.0 milestone Aug 30, 2023
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.

4 participants