-
Notifications
You must be signed in to change notification settings - Fork 12
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 rails 7.0 support and drop rails 6.1 #150
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0595547
Also test with rails 7, find all the broken things
jrafanie 877352a
Use Rails 7 interface for the Preloader
jrafanie 1b20dc5
Match rails 6.1/7.0 interface... no need to bind a block
kbrock d4d2df5
Bring over rails 7 grouped_records
kbrock ed0ed0c
Fix includes
kbrock 20b6106
Require Rails 7.0
kbrock 2905c1c
version 7.0.0 changelog
kbrock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module ActiveRecord | ||
module VirtualAttributes | ||
VERSION = "6.1.2".freeze | ||
VERSION = "7.0.0".freeze | ||
end | ||
end |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,7 @@ | |
end | ||
end | ||
end | ||
|
||
require "active_record" | ||
puts | ||
puts "\e[93mUsing ActiveRecord #{ActiveRecord.version}\e[0m" |
This file contains 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
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.
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.
EDIT: where is
call
being called originally? What's the entrypoint?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 question.
Sure, we do explicitly call it in our specs: https://github.com/kbrock/activerecord-virtual_attributes/blob/allow_rails_7/spec/virtual_includes_spec.rb#L542
But most of the time, it is called directly by rails.
From what I can tell, this is mostly called directly from preload_associations via exec_query.
https://github.com/rails/rails/blob/7-0-stable/activerecord/lib/active_record/relation.rb#L825-L832
I did try patching in that caller, but when we ran the preloader directly, this had issues - as you know since you had to skip those 3 tests before (we were since able to unskip).
So this fixes 18 specs (probably 50+ uses) in virtual_includes_specs like:
This
includes
value ends up in a Preloader. As you know, it is not valid. So we need to translate from the old includes values to the proper ones.Now I did try and just update
@associations
value directly, but that only worked if there were no additional levels, so many tests were still failing.This fix called allows us to get more complicated with our associations.
Coincidently, this recursive-ish solution is similar to the v6 changes where we call into self if the value changed. That was purely coincidental but brought me comfort.