aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra/relations/operations/having.rb
blob: d36aad071b9d0a73a2fd6509294089b480cec629 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Arel
  class Having < Compound
    attr_reader :predicates

    def initialize(relation, predicates)
      super(relation)
      @predicates = predicates.map { |p| p.bind(relation) }
    end

    def havings
      @havings ||= relation.havings + predicates
    end

    def == other
      super || Having === other &&
               relation == other.relation &&
               predicates == other.predicates
    end
  end
end