diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5cc5d3da..3ed5d25a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,9 +12,10 @@ jobs: strategy: matrix: ruby-version: - - '2.7' - - '3.0' - '3.1' + - '3.2' + - '3.3' + - '3.4' services: postgres: image: postgres:13 diff --git a/Gemfile b/Gemfile index 49ec9d52..918dd023 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" -gem "activerecord", "~>7.0.8" +gem "activerecord", "~>7.1.5" gem "mysql2" gem "pg" gem "sqlite3", "< 2" diff --git a/lib/active_record/virtual_attributes/virtual_delegates.rb b/lib/active_record/virtual_attributes/virtual_delegates.rb index a439110c..6de2d0c0 100644 --- a/lib/active_record/virtual_attributes/virtual_delegates.rb +++ b/lib/active_record/virtual_attributes/virtual_delegates.rb @@ -271,11 +271,9 @@ def self.select_from_alias(to_ref, col, to_model_col_name, src_model_id) def self.select_from_alias_table(to_klass, src_relation) to_table = to_klass.arel_table # if a self join, alias the second table to a different name - if to_table.table_name == src_relation.table_name - # use a dup to not modify the primary table in the model - to_table = to_table.dup + if to_table.name == src_relation.name # use a table alias to not conflict with table name in the primary query - to_table.table_alias = "#{to_table.table_name}_sub" + to_table = to_table.alias("#{to_table.name}_sub") end to_table end