Closed Dantemss closed 6 years ago
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @tenderlove (or someone else) soon.
If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.
Please see the contribution instructions for more information.
Oh also, while adding the new tests, I noticed that the eq_all
test was repeated, so I removed the second instance of it.
Could you use a shared example on the tests?
I believe this is similar to https://github.com/rails/arel/issues/368
Yes, I believe this may work as a patch for the issue reported in #368. I will attempt to convert these examples to shared examples... probably during the weekend though.
Per #523, Arel development is moving to rails/rails.
If this PR is still relevant, please consider reopening it over there.
This PR allows ARel to handle empty arrays in
grouping_any
andgrouping_all
.On master, when given an empty array:
grouping_any
throwsArel::Visitors::UnsupportedVisitError: Unsupported argument type: NilClass. Construct an Arel node instead.
grouping_all
returns invalid SQL:"SELECT \"users\".\"id\" FROM \"users\" WHERE ()"
This PR causes
grouping_any
to returnNodes::False.new
andgrouping_all
to returnNodes::True.new
instead. The reason for that is that is the behavior of[].any?
and[].all?
(with a block or not) and seems intuitive for normal use cases.Note: We could instead wrap the returned true/false nodes with a
Nodes::Grouping
. That would cause theTRUE
orFALSE
in the generated SQL to become(TRUE)
or(FALSE)
.The issue I was attempting to fix originally can be found here: https://github.com/activerecord-hackery/squeel/issues/376 but after investigating I concluded this was an ARel behavior, not a squeel behavior.