lib/active_house/querying/collect.rb in active_house-0.5.1 vs lib/active_house/querying/collect.rb in active_house-0.6.0

- old
+ new

@@ -85,12 +85,22 @@ def group_values values[:group_by].empty? ? nil : values[:group_by] end + def pluck(*fields) + result = except(:select).select(*fields).to_hashes + return [] if result.empty? + if result.first.keys.size == 1 + result.map { |row| row.values.first } + else + result.map(&:values) + end + end + def count(value = 'COUNT() AS cnt') return 0 if group_values - except(:select, :limit, :offset, :order).select(value).to_hashes.first.values.first + except(:select, :limit, :offset, :order).pluck(value).first end end end end