1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Remove duplicated attribute alias resolution in _select!

This is also resolved in `arel_column`.
This commit is contained in:
Ryuta Kamizono 2019-04-09 22:38:08 +09:00
parent 483d0dcb76
commit 2ab3751781
2 changed files with 4 additions and 6 deletions

View file

@ -252,9 +252,6 @@ module ActiveRecord
def _select!(*fields) # :nodoc:
fields.reject!(&:blank?)
fields.flatten!
fields.map! do |field|
klass.attribute_alias?(field) ? klass.attribute_alias(field).to_sym : field
end
self.select_values += fields
self
end
@ -1164,9 +1161,9 @@ module ActiveRecord
case field
when Symbol
field = field.to_s
arel_column(field) { connection.quote_table_name(field) }
arel_column(field, &connection.method(:quote_table_name))
when String
arel_column(field) { field }
arel_column(field, &:itself)
when Proc
field.call
else
@ -1182,7 +1179,7 @@ module ActiveRecord
if klass.columns_hash.key?(field) && (!from || table_name_matches?(from))
arel_attribute(field)
else
yield
yield field
end
end

View file

@ -292,6 +292,7 @@ module ActiveRecord
klass.create!(description: "foo")
assert_equal ["foo"], klass.select(:description).from(klass.all).map(&:desc)
assert_equal ["foo"], klass.reselect(:description).from(klass.all).map(&:desc)
end
def test_relation_merging_with_merged_joins_as_strings