diff options
author | Carl Lerche <carllerche@mac.com> | 2010-03-23 13:48:35 -0700 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-03-23 13:48:35 -0700 |
commit | 8991daa5e3077e31f90500fd52d77b69d979cc97 (patch) | |
tree | 80a2e67be833e6c75ac5554942f5ec9d7d71da55 /lib/arel/algebra/relations | |
parent | 09765829d38e78c0d260aac805c9f405a1523d56 (diff) | |
download | rails-8991daa5e3077e31f90500fd52d77b69d979cc97.tar.gz rails-8991daa5e3077e31f90500fd52d77b69d979cc97.tar.bz2 rails-8991daa5e3077e31f90500fd52d77b69d979cc97.zip |
Restrictions should be able to contain multiple predicates.
Diffstat (limited to 'lib/arel/algebra/relations')
-rw-r--r-- | lib/arel/algebra/relations/operations/where.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/arel/algebra/relations/operations/where.rb b/lib/arel/algebra/relations/operations/where.rb index 6c9c5ed755..5c50fe8640 100644 --- a/lib/arel/algebra/relations/operations/where.rb +++ b/lib/arel/algebra/relations/operations/where.rb @@ -1,17 +1,17 @@ module Arel class Where < Compound - attributes :relation, :predicate + attributes :relation, :predicates deriving :== requires :restricting def initialize(relation, *predicates, &block) - predicate = block_given?? yield(relation) : predicates.shift - @relation = predicates.empty?? relation : Where.new(relation, *predicates) - @predicate = predicate.bind(@relation) + predicates = [yield(relation)] + predicates if block_given? + @predicates = predicates.map { |p| p.bind(relation) } + @relation = relation end def wheres - @wheres ||= (relation.wheres + [predicate]).collect { |p| p.bind(self) } + @wheres ||= relation.wheres + predicates end end end |