aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/engines/sql
diff options
context:
space:
mode:
authorErnie Miller <ernie@metautonomo.us>2010-03-25 20:18:36 -0400
committerErnie Miller <ernie@metautonomo.us>2010-05-07 13:05:14 -0400
commit32fbb70f100d0d6f9800020ef519a09a0852ae47 (patch)
tree584136c3fec48b0db0e409bb3d6ff1b203b12ced /lib/arel/engines/sql
parentdef75c7b54ccc18f3a8daf79b6144ddcb538d4e8 (diff)
downloadrails-32fbb70f100d0d6f9800020ef519a09a0852ae47.tar.gz
rails-32fbb70f100d0d6f9800020ef519a09a0852ae47.tar.bz2
rails-32fbb70f100d0d6f9800020ef519a09a0852ae47.zip
Add grouped predicates (_any/_all) and refactored predication method definitions
Diffstat (limited to 'lib/arel/engines/sql')
-rw-r--r--lib/arel/engines/sql/predicates.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/arel/engines/sql/predicates.rb b/lib/arel/engines/sql/predicates.rb
index e9a068fb13..53bac7a2ca 100644
--- a/lib/arel/engines/sql/predicates.rb
+++ b/lib/arel/engines/sql/predicates.rb
@@ -19,6 +19,24 @@ module Arel
class And < CompoundPredicate
def predicate_sql; "AND" end
end
+
+ class GroupedPredicate < Grouped
+ def to_sql(formatter = nil)
+ "(" +
+ operands2.inject([]) { |predicates, operand|
+ predicates << operator.new(operand1, operand).to_sql
+ }.join(" #{predicate_sql} ") +
+ ")"
+ end
+ end
+
+ class Any < GroupedPredicate
+ def predicate_sql; "OR" end
+ end
+
+ class All < GroupedPredicate
+ def predicate_sql; "AND" end
+ end
class Equality < Binary
def predicate_sql