-
Notifications
You must be signed in to change notification settings - Fork 22.1k
[RF Docs] Active Record Query Interface #56341
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
Open
Ridhwana
wants to merge
49
commits into
rails:main
Choose a base branch
from
Ridhwana:Ridhwana/active-record-query-interface
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[RF Docs] Active Record Query Interface #56341
Ridhwana
wants to merge
49
commits into
rails:main
from
Ridhwana:Ridhwana/active-record-query-interface
+603
−317
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation / Background
This Pull Request has been created to imrove the Active Record Query Interface Guide
Detail
I kept it as is because I like that we show a real world holistic example
NOTE: I kept it as is because it avoids timezone confusion. Date.yesterday.all_day is evaluated in UTC by default, which can cause subtle differences between local and UTC times, especially if a developer’s config.time_zone is set to something else (e.g., "America/New_York" or "Pretoria"). Time.now.midnight (or, even better, Time.zone.now.midnight) makes the range clearly time-zone aware
statusinstead, like the other examples? grouped by status and customer_idNOTE: deferred
create_withis a finder method, so we can probably remove it from the list.Customer.allbefore the "Retrieving Multiple Objects in batches" section? Or maybe mentionwhereand all the other sections later on ("Conditions", "Ordering", "Limit", "Grouping", etc)?distinctsection seems somewhat out-of-place in the "Selecting Specific Fields" section. Maybe move it to "Limit and Offset" and rename that section to "Limiting Results"?find_by?pluckandids. Or maybe move thepluck,pickandidsmethods to the "Retrieving Objects from the Database" section under a new "Retrieving Columns" section?find_by_sqlshould have it's own heading, like the other methods have.https://edgeapi.rubyonrails.org/classes/ActiveRecord/Calculations.html#method-i-async_pluck
NOTE: tackle as a separate follow up task, maybe those could be added to an Advanced guide?
Additional information
Running EXPLAIN and eager loading can probably be moved to a Performance Guide as suggested. I did not attempt to do this as part of this task, but I will create a separate Basecamp task so that we can determine what else we'd move into this guide and how to give a full view of performance. Thereafter, we can extract it.
As per Carlos's and Petrik's suggestions, I agree that we can have a separate guide Active Model Transactions & Locking. However, I'd prefer to tackle this separately. Once we tackle this task, I'll move the content from here and other places to this new guide.
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]