Skip to content

Commit defbba0

Browse files
committed
Use a public API to set the table alias
Since they dropped the table_alias writer on the Arel::Table, we're no longer modifying it so we can drop the dup.
1 parent 978de6e commit defbba0

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

lib/active_record/virtual_attributes/virtual_delegates.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,8 @@ 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
274274
if to_table.name == src_relation.name
275-
# use a dup to not modify the primary table in the model
276-
to_table = to_table.dup
277275
# use a table alias to not conflict with table name in the primary query
278-
to_table.instance_variable_set(:@table_alias, "#{to_table.name}_sub")
276+
to_table = to_table.alias("#{to_table.name}_sub")
279277
end
280278
to_table
281279
end

0 commit comments

Comments
 (0)