Flowdock
method

construct_finder_sql_for_association_limiting

Importance_0
construct_finder_sql_for_association_limiting(options, join_dependency) 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/associations.rb, line 1323
        def construct_finder_sql_for_association_limiting(options, join_dependency)
          scope       = scope(:find)
          is_distinct = !options[:joins].blank? || include_eager_conditions?(options) || include_eager_order?(options)
          sql = "SELECT "
          if is_distinct
            sql << connection.distinct("#{connection.quote_table_name table_name}.#{primary_key}", options[:order])
          else
            sql << primary_key
          end
          sql << " FROM #{connection.quote_table_name table_name} "

          if is_distinct
            sql << join_dependency.join_associations.collect(&:association_join).join
            add_joins!(sql, options, scope)
          end

          add_conditions!(sql, options[:conditions], scope)
          add_group!(sql, options[:group], scope)

          if options[:order] && is_distinct
            connection.add_order_by_for_association_limiting!(sql, options)
          else
            add_order!(sql, options[:order], scope)
          end

          add_limit!(sql, options, scope)

          return sanitize_sql(sql)
        end
Register or log in to add new notes.