diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-15 19:26:18 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-15 19:26:18 -0700 |
commit | fdffe2160a4b855d7d9e611c6326f4a509c7cb07 (patch) | |
tree | 7d46d2869b1f5d680be82cc81bf5c3a67df4db9b /lib | |
parent | 4b300befaffd0486eb4ffbc63d64f04c85cd0219 (diff) | |
download | rails-fdffe2160a4b855d7d9e611c6326f4a509c7cb07.tar.gz rails-fdffe2160a4b855d7d9e611c6326f4a509c7cb07.tar.bz2 rails-fdffe2160a4b855d7d9e611c6326f4a509c7cb07.zip |
thinks must get worse before they get better
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel/relations/compound.rb | 6 | ||||
-rw-r--r-- | lib/arel/relations/join.rb | 14 | ||||
-rw-r--r-- | lib/arel/relations/nil.rb | 3 | ||||
-rw-r--r-- | lib/arel/relations/recursion.rb | 12 | ||||
-rw-r--r-- | lib/arel/relations/relation.rb | 4 |
5 files changed, 27 insertions, 12 deletions
diff --git a/lib/arel/relations/compound.rb b/lib/arel/relations/compound.rb index ca192a6e8a..94616ff14f 100644 --- a/lib/arel/relations/compound.rb +++ b/lib/arel/relations/compound.rb @@ -2,7 +2,7 @@ module Arel class Compound < Relation attr_reader :relation hash_on :relation - delegate :joins, :selects, :orders, :groupings, :inserts, :taken, + delegate :joins, :selects, :join?, :orders, :groupings, :inserts, :taken, :skipped, :name, :aggregation?, :column_for, :engine, :table, :table_sql, :to => :relation @@ -10,5 +10,9 @@ module Arel def attributes @attributes ||= relation.attributes.collect { |a| a.bind(self) } end + + def relation_for(attribute) + join? && relation.relation_for(attribute) || self[attribute] && self + end end end
\ No newline at end of file diff --git a/lib/arel/relations/join.rb b/lib/arel/relations/join.rb index d42af5a499..05ed6efc23 100644 --- a/lib/arel/relations/join.rb +++ b/lib/arel/relations/join.rb @@ -49,16 +49,18 @@ module Arel end end + def aggregation? + relation1.aggregation? or relation2.aggregation? + end + + def join? + true + end + private # FIXME - make instance method def externalize(relation) relation.aggregation?? Aggregation.new(relation) : relation end end - - class Relation - def relation_for(attribute) - self[attribute] && self - end - end end
\ No newline at end of file diff --git a/lib/arel/relations/nil.rb b/lib/arel/relations/nil.rb index b0d97dd174..34f9ea8722 100644 --- a/lib/arel/relations/nil.rb +++ b/lib/arel/relations/nil.rb @@ -1,6 +1,7 @@ module Arel class Nil < Relation - def table; self end + include Recursion::BaseCase + def table_sql(formatter = nil); '' end def relation_for(attribute); nil end def name; '' end diff --git a/lib/arel/relations/recursion.rb b/lib/arel/relations/recursion.rb index 848b059507..c5ca171fd2 100644 --- a/lib/arel/relations/recursion.rb +++ b/lib/arel/relations/recursion.rb @@ -8,6 +8,18 @@ module Arel def table_sql(formatter = Sql::TableReference.new(self)) formatter.table self end + + def relation_for(attribute) + self[attribute] && self + end + + def join? + false + end + + def aggregation? + false + end end end end
\ No newline at end of file diff --git a/lib/arel/relations/relation.rb b/lib/arel/relations/relation.rb index c576033938..884b743f20 100644 --- a/lib/arel/relations/relation.rb +++ b/lib/arel/relations/relation.rb @@ -39,10 +39,6 @@ module Arel @christener ||= Sql::Christener.new end - def aggregation? - false - end - module Enumerable include ::Enumerable |