aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_relation/primitives
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-03-16 16:53:49 -0700
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-03-16 16:53:49 -0700
commitaa5c9a19826c84bbb9c9f75f8d1a4b04b874780c (patch)
treec5a6720db91fed575f9fbd0b8de08de651def91c /lib/active_relation/primitives
parent07f7f752fecb56316456f144c121e471fd0d0847 (diff)
downloadrails-aa5c9a19826c84bbb9c9f75f8d1a4b04b874780c.tar.gz
rails-aa5c9a19826c84bbb9c9f75f8d1a4b04b874780c.tar.bz2
rails-aa5c9a19826c84bbb9c9f75f8d1a4b04b874780c.zip
added support for `attribute IN ...` and `attribute BETWEEN ...`
- IN and BETWEEN are chosen depending on the type of the second operand - ranges (1..2), arrays ([1,2,3]), and relations ("SELECT * ...") are all supported
Diffstat (limited to 'lib/active_relation/primitives')
-rw-r--r--lib/active_relation/primitives/attribute.rb4
-rw-r--r--lib/active_relation/primitives/value.rb2
2 files changed, 6 insertions, 0 deletions
diff --git a/lib/active_relation/primitives/attribute.rb b/lib/active_relation/primitives/attribute.rb
index 0ddbbb5cd4..ddf5ef5e07 100644
--- a/lib/active_relation/primitives/attribute.rb
+++ b/lib/active_relation/primitives/attribute.rb
@@ -85,6 +85,10 @@ module ActiveRelation
def matches(regexp)
Match.new(self, regexp)
end
+
+ def in(array)
+ In.new(self, array)
+ end
end
include Predications
diff --git a/lib/active_relation/primitives/value.rb b/lib/active_relation/primitives/value.rb
index 131610f2e9..aeee89dc3b 100644
--- a/lib/active_relation/primitives/value.rb
+++ b/lib/active_relation/primitives/value.rb
@@ -2,6 +2,8 @@ module ActiveRelation
class Value
attr_reader :value, :relation
+ delegate :predicate_sql, :to => :value
+
def initialize(value, relation)
@value, @relation = value, relation
end