method
construct_counter_sql
rails latest stable - Class:
ActiveRecord::Associations::AssociationCollection
construct_counter_sql()protected
No documentation available.
# File activerecord/lib/active_record/associations/association_collection.rb, line 382
def construct_counter_sql
if @reflection.options[:counter_sql]
@counter_sql = interpolate_and_sanitize_sql(@reflection.options[:counter_sql])
elsif @reflection.options[:finder_sql]
# replace the SELECT clause with COUNT(*), preserving any hints within /* ... */
@counter_sql = interpolate_and_sanitize_sql(@reflection.options[:finder_sql]).sub(/SELECT\b(\/\*.*?\*\/ )?(.*)\bFROM\b/m) { "SELECT #{$1}COUNT(*) FROM" }
else
@counter_sql = @finder_sql
end
end