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
Add endless range example to the Active Record Querying guide [ci-skip] #45617
Add endless range example to the Active Record Querying guide [ci-skip] #45617
Conversation
```ruby | ||
Book.where(created_at: (Time.now.midnight - 1.year)..) | ||
``` | ||
|
||
This would generate SQL like: | ||
|
||
```sql | ||
SELECT * FROM books WHERE books.created_at >= '2021-07-18 00:00:00' | ||
``` |
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.
For better comparison / contrast, what do you think about sticking more closely to the example just above this?
```ruby | |
Book.where(created_at: (Time.now.midnight - 1.year)..) | |
``` | |
This would generate SQL like: | |
```sql | |
SELECT * FROM books WHERE books.created_at >= '2021-07-18 00:00:00' | |
``` | |
```ruby | |
Book.where(created_at: (Time.now.midnight - 1.day)..) | |
``` | |
This would generate SQL like: | |
```sql | |
SELECT * FROM books WHERE books.created_at >= '2008-12-21 00:00:00' | |
``` |
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.
Great suggestion @jonathanhefner. I've made that change. Thanks for the review.
d51a008
to
504887c
Compare
Thank you, @ajporterfield! 😄 (Backported to |
…ple-to-ar-querying-guide Add endless range example to the Active Record Querying guide [ci-skip] (cherry picked from commit bc0f07b)
Summary
Beginless/endless ranges are something I recently discovered. I find them very handy and wish I would have known about them sooner. I think they're definitely worth mentioning in this guide.