Skip to content

Guard Function#alias visits for Rails 8.1 compatibility#3

Closed
lucasmenezesds wants to merge 1 commit into
masterfrom
rails-8.1-compatibility-fix
Closed

Guard Function#alias visits for Rails 8.1 compatibility#3
lucasmenezesds wants to merge 1 commit into
masterfrom
rails-8.1-compatibility-fix

Conversation

@lucasmenezesds

Copy link
Copy Markdown

Guard the visit obj.alias calls with respond_to?(:alias) to keep the visitor working on Rails 6/7/8.0 (where the attribute exists) and Rails 8.1+ (where it does not).

Rails 8.1 removed attr_accessor :alias from Arel::Nodes::Function (and dropped Arel::Visitors::DepthFirst itself), so the bundled MultiTenant::ArelVisitorsDepthFirst fallback raised NoMethodError when traversing Exists/Avg/Max/Min/Sum/NamedFunction/Count during the tenant-rewrite pass.

Guard the `visit obj.alias` calls with `respond_to?(:alias)` to keep the visitor working on Rails 6/7/8.0 (where the attribute exists) and Rails 8.1+ (where it does not).

Rails 8.1 removed `attr_accessor :alias` from `Arel::Nodes::Function` (and dropped `Arel::Visitors::DepthFirst` itself), so the bundled `MultiTenant::ArelVisitorsDepthFirst` fallback raised NoMethodError  when traversing Exists/Avg/Max/Min/Sum/NamedFunction/Count during the tenant-rewrite pass.
@lucasmenezesds

Copy link
Copy Markdown
Author

Closing this PR because I'm going to apply the same fix as a monkey-patch inside the project instead of carrying it over to the fork.

The change's impact would be broader than necessary and could negatively affect downstream consumers. Keeping the patch local to where it's used is the safer, more contained option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant