aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/arel/relations/relation.rb17
-rw-r--r--lib/arel/relations/table.rb5
2 files changed, 12 insertions, 10 deletions
diff --git a/lib/arel/relations/relation.rb b/lib/arel/relations/relation.rb
index 60fb7bd00a..c8602d22e3 100644
--- a/lib/arel/relations/relation.rb
+++ b/lib/arel/relations/relation.rb
@@ -18,19 +18,19 @@ module Arel
include Enumerable
module Operations
- def join(other = nil)
+ def join(other = nil, join_type = "INNER JOIN")
case other
when String
Join.new(other, self)
when Relation
- JoinOperation.new("INNER JOIN", self, other)
+ JoinOperation.new(join_type, self, other)
else
self
end
end
- def outer_join(other)
- JoinOperation.new("LEFT OUTER JOIN", self, other)
+ def outer_join(other = nil)
+ join(other, "LEFT OUTER JOIN")
end
def [](index)
@@ -39,6 +39,8 @@ module Arel
attribute_for_name(index)
when Attribute, Expression
attribute_for_attribute(index)
+ when Array
+ index.collect { |i| self[i] }
end
end
@@ -123,7 +125,12 @@ module Arel
end
def call(connection = engine.connection)
- connection.select_all(to_sql)
+ results = connection.execute(to_sql)
+ rows = []
+ results.each do |row|
+ rows << attributes.zip(row).to_hash
+ end
+ rows
end
module AttributeAccessors
diff --git a/lib/arel/relations/table.rb b/lib/arel/relations/table.rb
index cdc03df623..b627558caf 100644
--- a/lib/arel/relations/table.rb
+++ b/lib/arel/relations/table.rb
@@ -39,10 +39,5 @@ module Arel
def table_sql
engine.quote_table_name(name)
end
-
- private
- def qualifications
- attributes.zip(attributes.collect(&:qualified_name)).to_hash
- end
end
end \ No newline at end of file