-
Notifications
You must be signed in to change notification settings - Fork 51
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
rails 7.2+ support #132
base: master
Are you sure you want to change the base?
rails 7.2+ support #132
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 your contribution.
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec| | |||
|
|||
spec.files = Dir.glob('{lib/**/*,*.{md,txt,gemspec}}') | |||
|
|||
spec.add_dependency 'activerecord', '>= 6.1.5', '< 7.2' | |||
spec.add_dependency 'activerecord', '>= 6.1.5', '< 7.3' |
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.
can you please add Rails 7.1 and 7.2 to the testmatrix .github/workflows/build.yml
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.
kind of a noob on this one - would it need to be activerecord: ["~> 6.1", "~> 7.2"]
in build.yml
?
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 think it should be activerecord: ["~> 6.1", "~> 7.0" "~> 7.1" "~> 7.2"]
so everything is tested. But I'm not an expert here as well.
@@ -10,6 +10,11 @@ class VersionHelper | |||
# ::ActiveRecord::VERSION::MAJOR > 7 || | |||
# ::ActiveRecord::VERSION::MAJOR == 7 && ::ActiveRecord::VERSION::MINOR >= 1 | |||
# end | |||
|
|||
def self.at_least_7_2? | |||
::ActiveRecord::VERSION::MAJOR == 7 && ::ActiveRecord::VERSION::MINOR >= 2 |
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.
You need to add ::ActiveRecord::VERSION::MAJOR > 7 ||
if the changes also apply for Rails 8.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.
unclear if this will work on rails 8 at this time
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.
The name of the method suggests that it will apply to Rails 8.0.
I believe that the Associations::AliasTracker
is not reverting to a simple connection.
Even if there are issues in Version 8, it would be simpler to start with the Rails 7.2 changes rather than the Rails 7.1 changes.
ActiveRecord 8.0.0.rc2 is green with the changes you made. 👍
@@ -119,7 +119,7 @@ def build(relation, buckets) | |||
|
|||
join_list = join_nodes + joins | |||
|
|||
alias_tracker = Associations::AliasTracker.create(relation.klass.connection, relation.table.name, join_list) | |||
alias_tracker = Associations::AliasTracker.create(BabySqueel::ActiveRecord::VersionHelper.at_least_7_2? ? relation.klass.connection.pool : relation.klass.connection, relation.table.name, join_list) |
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.
Can you please point to the Documentation why this change is needed.
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.
the first param for the init method for Associations::AliasTracker
was changed to accept a pool
now: https://github.com/rails/rails/blob/v7.2.1.2/activerecord/lib/active_record/associations/alias_tracker.rb#L9
lib/baby_squeel/nodes/proxy.rb
Outdated
module BabySqueel | ||
module Nodes | ||
# This proxy class allows us to quack like any arel object. When a | ||
# method missing is hit, we'll instantiate a new proxy object. | ||
class Proxy < ActiveSupport::ProxyObject | ||
class Proxy < (BabySqueel::ActiveRecord::VersionHelper.at_least_7_2? ? BasicObject : ActiveSupport::ProxyObject) |
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.
Do we need a version check here or does the BasicObject
also work in older versions?
ActiveSupport::ProxyObject will be removed: https://github.com/rails/rails/blob/v7.2.1.1/activesupport/lib/active_support/proxy_object.rb
MR: rails/rails@ea7d3c5
Was that part importent?
undef_method :==
undef_method :equal?
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.
good catch here - the gist of this was they deprecated ActiveSupport:Proxy
in favor of BaseObject
- I tested BaseObject
against 6.x and 7.x and it does seem to work just fine.
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec| | |||
|
|||
spec.files = Dir.glob('{lib/**/*,*.{md,txt,gemspec}}') | |||
|
|||
spec.add_dependency 'activerecord', '>= 6.1.5', '< 7.2' | |||
spec.add_dependency 'activerecord', '>= 6.1.5', '< 7.3' |
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 think it should be activerecord: ["~> 6.1", "~> 7.0" "~> 7.1" "~> 7.2"]
so everything is tested. But I'm not an expert here as well.
@@ -10,6 +10,11 @@ class VersionHelper | |||
# ::ActiveRecord::VERSION::MAJOR > 7 || | |||
# ::ActiveRecord::VERSION::MAJOR == 7 && ::ActiveRecord::VERSION::MINOR >= 1 | |||
# end | |||
|
|||
def self.at_least_7_2? | |||
::ActiveRecord::VERSION::MAJOR == 7 && ::ActiveRecord::VERSION::MINOR >= 2 |
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.
The name of the method suggests that it will apply to Rails 8.0.
I believe that the Associations::AliasTracker
is not reverting to a simple connection.
Even if there are issues in Version 8, it would be simpler to start with the Rails 7.2 changes rather than the Rails 7.1 changes.
ActiveRecord 8.0.0.rc2 is green with the changes you made. 👍
Hi, is there any update on this? We're looking forward to upgrade to rails 7.2 and waiting for this compatibility support 🙂 |
a few minor changes - left it backwards compatible with 6.1.5. All tests passing 👍