Skip to content

Conversation

codelight89
Copy link
Contributor

Fixes this issue #6281

@codelight89 codelight89 force-pushed the belongs-to-many-chunk branch from 50cdf5c to 371e17e Compare March 18, 2015 10:59
@GrahamCampbell
Copy link
Member

Tests?

@codelight89 codelight89 force-pushed the belongs-to-many-chunk branch 3 times, most recently from 6b0c7fc to e098e6c Compare March 19, 2015 15:33
$callbackExecutionAssertor->shouldReceive('checkModelNameAttribute')->with('dayle')->once();
$callbackExecutionAssertor->shouldReceive('checkModelNameAttribute')->with('graham')->once();
$callbackExecutionAssertor->shouldReceive('checkForeignKey')->with('user_id')->times(3);
$callbackExecutionAssertor->shouldReceive('checkOtherKey')->with('role_id')->times(3);
Copy link
Member

Choose a reason for hiding this comment

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

Wooooow. That's not a good amount of mocking. Better not to mock this.

@codelight89 codelight89 force-pushed the belongs-to-many-chunk branch from 71e7345 to e098e6c Compare March 20, 2015 07:31
@codelight89
Copy link
Contributor Author

I don't know what "cs" means, but check it, please. =)

@GrahamCampbell
Copy link
Member

Code style/coding standard. You need to put all braces on their own line.

@codelight89
Copy link
Contributor Author

Done. And what about this bug in other versions of laravel?

@GrahamCampbell
Copy link
Member

Done. And what about this bug in other versions of laravel?

There are no plans to backport this fix to 4.x. If it's merged into 5.0, we always merge 5.0 -> 5.1, so it'll be included in all 5.x releases.

// On each chunk result set, we will pass them to the callback and then let the
// developer take care of everything within the callback, which allows us to
// keep the memory low for spinning through large result sets for working.
call_user_func($callback, $result);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this check for false like the query builder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there is no check in the eloquent builder

Copy link
Member

Choose a reason for hiding this comment

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

Yes there is. Follow the link Joseph provided.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, right I see. Maybe the Eloquent builder needs a check then?

Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, is there any reason this logic is duplicated all over the place?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure, would be nice to abstract it. Would a trait do the job?

Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason the eloquent builder doesn't just call it directly on the base query builder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This chunk functions are equivalent except called get()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually the same realization of method (like in Query Builder) must work in BelognsToMany class too. Maybe it is a reason to create ChunkableTrait with this method and use it in Query Builder, Eloquent Builder and BelongsToMany Relation?

@GrahamCampbell GrahamCampbell changed the title Eloquent belongsToMany chunk [5.0] Eloquent belongsToMany chunk Mar 20, 2015
@codelight89
Copy link
Contributor Author

So you will merge this pull request? Or better to do it as I described above (with trait).

@GrahamCampbell
Copy link
Member

Taylor is the one who decides what gets merged, particularly for sensitive components like the database component.

@codelight89 codelight89 force-pushed the belongs-to-many-chunk branch from bb946df to 1a4bb2b Compare March 23, 2015 20:04
@taylorotwell
Copy link
Member

Is it not possible to just add the select fields and then call the usual chunk method on the Eloquent builder? Why duplicate the logic?

@codelight89
Copy link
Contributor Author

@taylorotwell, I don't think it can be solved this way. We need to hydrate pivot relation for every chunk result that we pass to callback.

@taylorotwell
Copy link
Member

Yeah you could pass it to the callback, and then call the user supplied callback from that callback. Make sense? :)

@codelight89 codelight89 force-pushed the belongs-to-many-chunk branch from 1a4bb2b to 33687a1 Compare March 25, 2015 23:40
@codelight89
Copy link
Contributor Author

@taylorotwell, check it. :)

@taylorotwell
Copy link
Member

Is this tested? Do we need an integration test here?

@codelight89 codelight89 force-pushed the belongs-to-many-chunk branch from dad9a01 to c39cbce Compare March 26, 2015 17:16
@codelight89
Copy link
Contributor Author

@taylorotwell, I added a small test. Think that's enough.

taylorotwell added a commit that referenced this pull request Apr 4, 2015
@taylorotwell taylorotwell merged commit 38439a5 into laravel:5.0 Apr 4, 2015
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.

5 participants