Method: ActiveRecord::Extensions::FinderOptions::HavingOptionBackCompatibility::ClassMethods#add_group_with_having!

Defined in:
lib/ar-extensions/finder_options.rb

#add_group_with_having!(sql, group, having, scope = :auto) ⇒ Object

add_group! in version 2.3 adds having already copy that implementation



243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/ar-extensions/finder_options.rb', line 243

def add_group_with_having!(sql, group, having, scope =:auto)#:nodoc:
  if group
    sql << " GROUP BY #{group}"
    sql << " HAVING #{sanitize_sql(having)}" if having
  else
    scope = scope(:find) if :auto == scope
    if scope && (scoped_group = scope[:group])
      sql << " GROUP BY #{scoped_group}"
      sql << " HAVING #{sanitize_sql(scope[:having])}" if scope[:having]
    end
  end
end