Skip to content
This repository
Browse code

Relation#merge and Relation#except should respect havings

  • Loading branch information...
commit 3db876cb761837ebf9b02d22846353e277ff14cd 1 parent af5e1b4
Pratik authored January 03, 2010
4  activerecord/lib/active_record/relation/spawn_methods.rb
@@ -23,7 +23,8 @@ def merge(r)
23 23
           limit(arel.taken).
24 24
           offset(arel.skipped).
25 25
           select(arel.send(:select_clauses)).
26  
-          from(arel.sources)
  26
+          from(arel.sources).
  27
+          having(arel.havings)
27 28
       end
28 29
 
29 30
       relation_order = r.send(:order_clause)
@@ -63,6 +64,7 @@ def except(*skips)
63 64
       result = result.from(@relation.sources) unless skips.include?(:from)
64 65
       result = result.order(order_clause) unless skips.include?(:order)
65 66
       result = result.where(*@relation.wheres) unless skips.include?(:where)
  67
+      result = result.having(*@relation.havings) unless skips.include?(:having)
66 68
 
67 69
       result
68 70
     end

0 notes on commit 3db876c

Please sign in to comment.
Something went wrong with that request. Please try again.