Skip to content
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

[8.x] Add exception to chunkById() when last id cannot be determined #37294

Merged
merged 3 commits into from
May 10, 2021

Conversation

phpfour
Copy link
Contributor

@phpfour phpfour commented May 7, 2021

When chunkById is used in a query with joins, it creates an infinite loop if $column is provided but $alias is not provided.

This change makes sure If it is not possible to determine $lastId, then an exception is thrown because it is a fundamental requirement for the chunkById method to work.

Issue: #37289

@taylorotwell
Copy link
Member

We would need to make the exception message more informative. The user won't have a good idea what to do with this message.

@deleugpn
Copy link
Contributor

deleugpn commented May 7, 2021

throw new RuntimeException("chunkById aborted because the column [$alias] is not present in the query result, which will result in an infinite loop caused by the constraint `WHERE $column > null`.");

@taylorotwell taylorotwell merged commit e4ce9c5 into laravel:8.x May 10, 2021
@phpfour
Copy link
Contributor Author

phpfour commented May 10, 2021

We would need to make the exception message more informative. The user won't have a good idea what to do with this message.

@taylorotwell thanks for merging this...I was out of town so wasn't able to get back earlier. This would be my first contribution to the framework, so I am excited even with this small input ☺️

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.

None yet

3 participants