build_arel(aliases) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/relation/query_methods.rb, line 1136
      def build_arel(aliases)
        arel = Arel::SelectManager.new(table)

        build_joins(arel.join_sources, aliases)

        arel.where(where_clause.ast) unless where_clause.empty?
        arel.having(having_clause.ast) unless having_clause.empty?
        arel.take(build_cast_value("LIMIT", connection.sanitize_limit(limit_value))) if limit_value
        arel.skip(build_cast_value("OFFSET", offset_value.to_i)) if offset_value
        arel.group(*arel_columns(group_values.uniq)) unless group_values.empty?

        build_order(arel)
        build_select(arel)

        arel.optimizer_hints(*optimizer_hints_values) unless optimizer_hints_values.empty?
        arel.distinct(distinct_value)
        arel.from(build_from) unless from_clause.empty?
        arel.lock(lock_value) if lock_value

        unless annotate_values.empty?
          annotates = annotate_values
          annotates = annotates.uniq if annotates.size > 1
          unless annotates == annotate_values
            ActiveSupport::Deprecation.warn(              Duplicated query annotations are no longer shown in queries in Rails 6.2.              To migrate to Rails 6.2's behavior, use `uniq!(:annotate)` to deduplicate query annotations              (`#{klass.name&.tableize || klass.table_name}.uniq!(:annotate)`)..squish)
            annotates = annotate_values
          end
          arel.comment(*annotates)
        end

        arel
      end
Register or log in to add new notes.