mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
use ARel rather than generate SQL strings
This commit is contained in:
@@ -33,10 +33,11 @@ module ActiveRecord
|
||||
join_parts.first
|
||||
end
|
||||
|
||||
def columns(connection)
|
||||
def columns
|
||||
join_parts.collect { |join_part|
|
||||
table = Arel::Nodes::TableAlias.new join_part.aliased_table_name, nil
|
||||
join_part.column_names_with_alias.collect{ |column_name, aliased_name|
|
||||
"#{connection.quote_table_name join_part.aliased_table_name}.#{connection.quote_column_name column_name} AS #{aliased_name}"
|
||||
table[column_name].as aliased_name
|
||||
}
|
||||
}.flatten
|
||||
end
|
||||
|
||||
@@ -202,7 +202,7 @@ module ActiveRecord
|
||||
end
|
||||
|
||||
def construct_relation_for_association_find(join_dependency)
|
||||
relation = except(:includes, :eager_load, :preload, :select).select(join_dependency.columns(connection))
|
||||
relation = except(:includes, :eager_load, :preload, :select).select(join_dependency.columns)
|
||||
apply_join_dependency(relation, join_dependency)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user