-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.2] Fix each when there's no order by #11623
Conversation
@@ -295,6 +295,10 @@ public function chunk($count, callable $callback) | |||
*/ | |||
public function each(callable $callback, $count = 1000) | |||
{ | |||
if (is_null($this->getOrderBys())) { | |||
$this->orderBy('id', 'asc'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id
may not always be available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh, I know. Not sure what else we can do here.
Ok, I've made another change. |
*/ | ||
public function each(callable $callback, $count = 1000) | ||
{ | ||
if (is_null($this->getOrderBys())) { | ||
throw new RuntimeException('You must provided an ordering on the query.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably be "provide"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh, oops. Thanks. ;)
@GrahamCampbell maybe they should be modified as well for 5.4? |
Perhaps. Feel free to send a PR for Taylor to review. Thanks. :) |
Unless we add an orderby, the rows returned by chunk are undefined, the 2nd chunk could be the same as the first chunk for instance.