Module: ActiveRecord::Precount::JoinDependencyExtension
- Defined in:
- lib/active_record/precount/join_dependency_extension.rb
Defined Under Namespace
Classes: CountTable
Instance Method Summary collapse
Instance Method Details
#aliases ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/active_record/precount/join_dependency_extension.rb', line 10 def aliases Associations::JoinDependency::Aliases.new join_root.each_with_index.map { |join_part,i| if join_part.is_a?(Associations::JoinDependency::JoinAssociation) && join_part.reflection.macro == :count_loader # select COUNT(primary_key) column_name = join_part.reflection.klass.primary_key column = Associations::JoinDependency::Aliases::Column.new column_name, "t#{i}_r0" CountTable.new(join_part, [column]) else # original aliases' internal function columns = join_part.column_names.each_with_index.map { |column_name,j| Associations::JoinDependency::Aliases::Column.new column_name, "t#{i}_r#{j}" } Associations::JoinDependency::Aliases::Table.new(join_part, columns) end } end |