aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra/relations/operations/having.rb
blob: 447e836c1ae7c85eb525e1ecf16e9ff70a66e91c (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