diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-16 16:53:49 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-16 16:53:49 -0700 |
commit | aa5c9a19826c84bbb9c9f75f8d1a4b04b874780c (patch) | |
tree | c5a6720db91fed575f9fbd0b8de08de651def91c /lib/active_relation/relations | |
parent | 07f7f752fecb56316456f144c121e471fd0d0847 (diff) | |
download | rails-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/relations')
-rw-r--r-- | lib/active_relation/relations/relation.rb | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/active_relation/relations/relation.rb b/lib/active_relation/relations/relation.rb index 8c93f948f7..1364911f0c 100644 --- a/lib/active_relation/relations/relation.rb +++ b/lib/active_relation/relations/relation.rb @@ -37,10 +37,6 @@ module ActiveRelation end end - def include?(attribute) - RelationInclusion.new(attribute, self) - end - def select(*predicates) Selection.new(self, *predicates.collect {|p| p.bind(self)}) end @@ -94,13 +90,16 @@ module ActiveRelation end include Operations - def aggregation? - false - end + module Externalizable + def aggregation? + false + end - def alias? - false + def alias? + false + end end + include Externalizable def to_sql(formatter = Sql::SelectStatement.new(engine)) formatter.select [ @@ -116,6 +115,10 @@ module ActiveRelation end alias_method :to_s, :to_sql + def predicate_sql + "IN" + end + def call(connection = engine.connection) connection.select_all(to_sql) end |