diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-04-24 21:48:00 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-04-24 21:48:00 -0300 |
commit | 45646ec54c4c4a3c7340b79deea9e3cf76554f0b (patch) | |
tree | 2967aa6a6b4363fdc174fd83b7dd4bd57cd4e4dd /lib/arel | |
parent | 1b1fc880bf7129a422901417bd6b9fede292aa7e (diff) | |
download | rails-45646ec54c4c4a3c7340b79deea9e3cf76554f0b.tar.gz rails-45646ec54c4c4a3c7340b79deea9e3cf76554f0b.tar.bz2 rails-45646ec54c4c4a3c7340b79deea9e3cf76554f0b.zip |
Added aggregation and to_attribute methods to Value
Diffstat (limited to 'lib/arel')
-rw-r--r-- | lib/arel/primitives/value.rb | 8 | ||||
-rw-r--r-- | lib/arel/relations/operations/join.rb | 16 | ||||
-rw-r--r-- | lib/arel/relations/utilities/externalization.rb | 12 |
3 files changed, 22 insertions, 14 deletions
diff --git a/lib/arel/primitives/value.rb b/lib/arel/primitives/value.rb index 74baa06e5b..36a7fb7c71 100644 --- a/lib/arel/primitives/value.rb +++ b/lib/arel/primitives/value.rb @@ -16,5 +16,13 @@ module Arel def bind(relation) Value.new(value, relation) end + + def aggregation? + false + end + + def to_attribute + value + end end end diff --git a/lib/arel/relations/operations/join.rb b/lib/arel/relations/operations/join.rb index a72030abf9..8fe89358d8 100644 --- a/lib/arel/relations/operations/join.rb +++ b/lib/arel/relations/operations/join.rb @@ -8,11 +8,11 @@ module Arel def initialize(join_sql, relation1, relation2 = Nil.instance, *predicates) @join_sql, @relation1, @relation2, @predicates = join_sql, relation1, relation2, predicates end - + def table_sql(formatter = Sql::TableReference.new(self)) relation1.externalize.table_sql(formatter) end - + def joins(environment, formatter = Sql::TableReference.new(environment)) @joins ||= begin this_join = [ @@ -29,29 +29,29 @@ module Arel @attributes ||= (relation1.externalize.attributes + relation2.externalize.attributes).collect { |a| a.bind(self) } end - + def wheres # TESTME bind to self? relation1.externalize.wheres end - + def ons @ons ||= @predicates.collect { |p| p.bind(self) } end - + # TESTME def externalizable? relation1.externalizable? or relation2.externalizable? end - + def join? true end end - + class Relation def join? false end end -end
\ No newline at end of file +end diff --git a/lib/arel/relations/utilities/externalization.rb b/lib/arel/relations/utilities/externalization.rb index 4e9139a78a..3b9b2296dc 100644 --- a/lib/arel/relations/utilities/externalization.rb +++ b/lib/arel/relations/utilities/externalization.rb @@ -7,28 +7,28 @@ module Arel def wheres [] end - + def table_sql(formatter = Sql::TableReference.new(relation)) formatter.select relation.select_sql, self end - + def attributes @attributes ||= relation.attributes.collect(&:to_attribute).collect { |a| a.bind(self) } end - + # REMOVEME def name relation.name + '_external' end end - + class Relation def externalize @externalized ||= externalizable?? Externalization.new(self) : self end - + def externalizable? false end end -end
\ No newline at end of file +end |