-
Notifications
You must be signed in to change notification settings - Fork 21.9k
Update documentation #any? #many? [ci-skip] #43743
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
Update documentation #any? #many? [ci-skip] #43743
Conversation
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.
Thank you for working on this. When you are happy with the changes, would you mind squashing the commits?
Order.shipped.any? # => SELECT 1 AS one FROM orders WHERE orders.status = 0 | ||
Order.shipped.many? # => SELECT COUNT(*) FROM orders WHERE orders.status = 0 |
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.
What is the reason for removing these? Would adding LIMIT
clauses to these be more clear?
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.
I removed them because I thought it would be cleaner, though I wasn't sure tbh 👍
I re-added them and squashed commits 👍
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.
I removed them because I thought it would be cleaner, though I wasn't sure tbh
I see what you mean. The rendered output is getting a little crowded. What if we omit the SQL aliases, and put the SQL statements on separate lines? (I've added suggestions to illustrate.)
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.
I updated it 🏄 .
You are right, it looks cleaner now without the aliases.
I guess this final version is better in terms of readability, we are on the other hand saying that:
- it is not necessary for the reader to know the exact query executed from the guides (as we are omitting the aliases)
- we are saying in a way that it is more useful that the reader knows there is a limit in the query than knowing there are aliases in the real 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.
- it is not necessary for the reader to know the exact query executed from the guides (as we are omitting the aliases)
- we are saying in a way that it is more useful that the reader knows there is a limit in the query than knowing there are aliases in the real query
I think that is fine. 👍 Those aliases don't really provide much information. But it can be useful to know that Rails is smart enough to include a LIMIT
, so that we don't have to worry about adding it ourselves.
afb97f4
to
e909767
Compare
Order.shipped.any? # => SELECT 1 AS one FROM orders WHERE orders.status = 0 | ||
Order.shipped.many? # => SELECT COUNT(*) FROM orders WHERE orders.status = 0 |
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.
I removed them because I thought it would be cleaner, though I wasn't sure tbh
I see what you mean. The rendered output is getting a little crowded. What if we omit the SQL aliases, and put the SQL statements on separate lines? (I've added suggestions to illustrate.)
e909767
to
5d985f2
Compare
Thank you, @martinjaimem! 🎉 |
Summary
Update the documentation of the guides to reflect that
#any?
and#many?
uselimit
.