aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/TODO2
-rw-r--r--lib/arel/relations/order.rb12
-rw-r--r--spec/arel/unit/relations/order_spec.rb15
3 files changed, 6 insertions, 23 deletions
diff --git a/doc/TODO b/doc/TODO
index a51a730c90..3aa7696952 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -1,5 +1,4 @@
todo:
-- rename Arel to arel
- incorporate linq vocabularity
- fix complex joining cases:
- extract adapters
@@ -57,6 +56,7 @@ done:
- test relation, table reset
- test Value, in particular bind.
- test blank checks in relation.rb
+- rename active_relation to arel
icebox:
- #bind in Attribute and Expression should be doing a descend?
diff --git a/lib/arel/relations/order.rb b/lib/arel/relations/order.rb
index 91526da02c..b1454973c8 100644
--- a/lib/arel/relations/order.rb
+++ b/lib/arel/relations/order.rb
@@ -1,21 +1,15 @@
module Arel
class Order < Compound
- attr_reader :ordering
+ attr_reader :orders
def initialize(relation, *orders)
- ordering = orders.pop
- @relation = orders.empty?? relation : Order.new(relation, *orders)
- @ordering = ordering.bind(@relation)
+ @relation, @orders = relation, orders.collect { |o| o.bind(relation) }
end
def ==(other)
self.class == other.class and
relation == other.relation and
- ordering == other.ordering
- end
-
- def orders
- relation.orders + [ordering]
+ orders == other.orders
end
end
end \ No newline at end of file
diff --git a/spec/arel/unit/relations/order_spec.rb b/spec/arel/unit/relations/order_spec.rb
index 838a2f141e..514612f047 100644
--- a/spec/arel/unit/relations/order_spec.rb
+++ b/spec/arel/unit/relations/order_spec.rb
@@ -7,17 +7,6 @@ module Arel
@attribute = @relation[:id]
end
- describe '#initialize' do
- before do
- @another_attribtue = @relation[:name]
- end
-
- it "manufactures nested Order relations if multiple predicates are provided" do
- Order.new(@relation, @predicate, @another_attribute). \
- should == Order.new(Order.new(@relation, @another_attribute), @predicate)
- end
- end
-
describe '#to_sql' do
describe "when given an attribute" do
it "manufactures sql with an order clause populated by the attribute" do
@@ -63,11 +52,11 @@ module Arel
@another_attribute = @relation[:name]
end
- it "manufactures sql with an order clause populated by comma-separated attributes" do
+ it "manufactures sql with the order clause of the last ordering" do
Order.new(@ordered_relation, @another_attribute).to_sql.should be_like("
SELECT `users`.`id`, `users`.`name`
FROM `users`
- ORDER BY `users`.`id`, `users`.`name`
+ ORDER BY `users`.`name`
")
end
end