Skip to content

Commit 34873a9

Browse files
committed
Arel::Table changes in rails 7.1
Rails 7.1 removed the table_name alias to name so just use name: See: https://www.github.com/rails/rails/pull/46864 Rails 7.1 removed the writer for the table_alias so set the instance variable. We will need to see if there is a way to do this that's less brittle. See: https://www.github.com/rails/rails/pull/48927
1 parent eb351fc commit 34873a9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/active_record/virtual_attributes/virtual_delegates.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,11 @@ def self.select_from_alias(to_ref, col, to_model_col_name, src_model_id)
271271
def self.select_from_alias_table(to_klass, src_relation)
272272
to_table = to_klass.arel_table
273273
# if a self join, alias the second table to a different name
274-
if to_table.table_name == src_relation.table_name
274+
if to_table.name == src_relation.name
275275
# use a dup to not modify the primary table in the model
276276
to_table = to_table.dup
277277
# use a table alias to not conflict with table name in the primary query
278-
to_table.table_alias = "#{to_table.table_name}_sub"
278+
to_table.instance_variable_set(:@table_alias, "#{to_table.name}_sub")
279279
end
280280
to_table
281281
end

0 commit comments

Comments
 (0)