instance method
build_arel
Ruby on Rails 6.1.7.10
Since v3.0.20 PrivateSignature
build_arel(aliases = nil)
No documentation comment.
Parameters
-
aliasesopt = nil
Source
# File activerecord/lib/active_record/relation/query_methods.rb, line 1138
def build_arel(aliases = nil)
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(<<-MSG.squish)
Duplicated query annotations are no longer shown in queries in Rails 7.0.
To migrate to Rails 7.0's behavior, use `uniq!(:annotate)` to deduplicate query annotations
(`#{klass.name&.tableize || klass.table_name}.uniq!(:annotate)`).
MSG
annotates = annotate_values
end
arel.comment(*annotates)
end
arel
end
Defined in activerecord/lib/active_record/relation/query_methods.rb line 1138
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::QueryMethods