Flowdock
method

construct_counter_sql

Importance_0
Ruby on Rails latest stable (v4.0.2) - 0 notes - Class: ActiveRecord::Associations::AssociationCollection

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v3.0.9) is shown here.

construct_counter_sql() protected

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/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
Register or log in to add new notes.