diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-27 14:37:11 -0700 |
---|---|---|
committer | Bryan Helmkamp <bryan@brynary.com> | 2009-05-17 15:46:19 -0400 |
commit | 20b28b441b651d0404d64049253898c061a039be (patch) | |
tree | 4b9a8fc9e8f9207017248f129550c0283b0f520b /lib/arel/engines | |
parent | 2fe585328d6a24df310d3e60059c9c7b05b64bac (diff) | |
download | rails-20b28b441b651d0404d64049253898c061a039be.tar.gz rails-20b28b441b651d0404d64049253898c061a039be.tar.bz2 rails-20b28b441b651d0404d64049253898c061a039be.zip |
using in memory relations as results from sql relation
Conflicts:
lib/arel/algebra/primitives/expression.rb
lib/arel/algebra/relations/relation.rb
Diffstat (limited to 'lib/arel/engines')
-rw-r--r-- | lib/arel/engines/memory/relations.rb | 1 | ||||
-rw-r--r-- | lib/arel/engines/memory/relations/array.rb | 4 | ||||
-rw-r--r-- | lib/arel/engines/memory/relations/relation.rb | 7 | ||||
-rw-r--r-- | lib/arel/engines/sql/engine.rb | 10 | ||||
-rw-r--r-- | lib/arel/engines/sql/relations/operations/join.rb | 2 |
5 files changed, 8 insertions, 16 deletions
diff --git a/lib/arel/engines/memory/relations.rb b/lib/arel/engines/memory/relations.rb index 820b0af4b2..1b009537b9 100644 --- a/lib/arel/engines/memory/relations.rb +++ b/lib/arel/engines/memory/relations.rb @@ -1,4 +1,3 @@ -require 'arel/engines/memory/relations/relation' require 'arel/engines/memory/relations/array' require 'arel/engines/memory/relations/operations' require 'arel/engines/memory/relations/compound' diff --git a/lib/arel/engines/memory/relations/array.rb b/lib/arel/engines/memory/relations/array.rb index ea0b5af5ba..15a3e95e1b 100644 --- a/lib/arel/engines/memory/relations/array.rb +++ b/lib/arel/engines/memory/relations/array.rb @@ -1,8 +1,8 @@ module Arel class Array < Relation attributes :array, :attribute_names - deriving :initialize include Recursion::BaseCase + deriving :==, :initialize def engine @engine ||= Memory::Engine.new @@ -10,7 +10,7 @@ module Arel def attributes @attributes ||= @attribute_names.collect do |name| - Attribute.new(self, name.to_sym) + name.to_attribute(self) end end diff --git a/lib/arel/engines/memory/relations/relation.rb b/lib/arel/engines/memory/relations/relation.rb deleted file mode 100644 index abfb8bb37f..0000000000 --- a/lib/arel/engines/memory/relations/relation.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Arel - class Relation - def position_of(attribute) - attributes.index(self[attribute]) - end - end -end
\ No newline at end of file diff --git a/lib/arel/engines/sql/engine.rb b/lib/arel/engines/sql/engine.rb index e5d1a8b0ca..0700ae9733 100644 --- a/lib/arel/engines/sql/engine.rb +++ b/lib/arel/engines/sql/engine.rb @@ -19,12 +19,12 @@ module Arel end def read(relation) - results = connection.execute(relation.to_sql) - rows = [] - results.each do |row| - rows << attributes.zip(row).to_hash + # FIXME + class << rows = connection.execute(relation.to_sql) + include Enumerable end - rows + + Array.new(rows, relation.attributes) end def update(relation) diff --git a/lib/arel/engines/sql/relations/operations/join.rb b/lib/arel/engines/sql/relations/operations/join.rb index 2f5e23644e..f848fd3268 100644 --- a/lib/arel/engines/sql/relations/operations/join.rb +++ b/lib/arel/engines/sql/relations/operations/join.rb @@ -22,7 +22,7 @@ module Arel end class OuterJoin < Join - def join_sql; "OUTER JOIN" end + def join_sql; "LEFT OUTER JOIN" end end class StringJoin < Join |