lib/active_median/model.rb in active_median-0.2.6 vs lib/active_median/model.rb in active_median-0.2.7
- old
+ new
@@ -64,9 +64,12 @@
select(*group_values, "PERCENTILE_CONT(#{percentile}) WITHIN GROUP (ORDER BY #{column})")
else
raise "Connection adapter not supported: #{connection.adapter_name}"
end
+ # same as average
+ relation = relation.unscope(:order).distinct!(false) if relation.group_values.empty?
+
result = connection.select_all(relation.to_sql)
# typecast
rows = []
columns = result.columns