Skip to content
This repository
Browse code

Get rid of Relation#order_clauses

  • Loading branch information...
commit 8bb527464845071ee72bcbcddcf860d4af1eda32 1 parent 8ba2902
Pratik authored January 18, 2010
16  activerecord/lib/active_record/relation.rb
@@ -50,14 +50,14 @@ def to_a
50 50
       @records = if find_with_associations
51 51
         begin
52 52
           options = {
53  
-            :select => @select_values.any? ? @select_values.join(", ") : nil,
  53
+            :select => @select_values.join(", "),
54 54
             :joins => arel.joins(arel),
55  
-            :group =>  @group_values.any? ? @group_values.join(", ") : nil,
56  
-            :order => order_clause,
  55
+            :group =>  @group_values.join(", "),
  56
+            :order => @order_values.join(', '),
57 57
             :conditions => where_clause,
58  
-            :limit => arel.taken,
59  
-            :offset => arel.skipped,
60  
-            :from => (arel.send(:from_clauses) if arel.send(:sources).present?)
  58
+            :limit => @limit_value,
  59
+            :offset => @offset_value,
  60
+            :from => @from_value
61 61
           }
62 62
 
63 63
           including = (@eager_load_values + @includes_values).uniq
@@ -185,10 +185,6 @@ def where_clause(join_string = " AND ")
185 185
       arel.send(:where_clauses).join(join_string)
186 186
     end
187 187
 
188  
-    def order_clause
189  
-      @order_clause ||= arel.send(:order_clauses).join(', ')
190  
-    end
191  
-
192 188
     def references_eager_loaded_tables?
193 189
       joined_tables = (tables_in_string(arel.joins(arel)) + [table.name, table.table_alias]).compact.uniq
194 190
       (tables_in_string(to_sql) - joined_tables).any?
6  activerecord/test/cases/method_scoping_test.rb
@@ -608,7 +608,7 @@ def test_default_scope_with_conditions_hash
608 608
 
609 609
   def test_default_scoping_with_threads
610 610
     2.times do
611  
-      Thread.new { assert_equal 'salary DESC', DeveloperOrderedBySalary.scoped.send(:order_clause) }.join
  611
+      Thread.new { assert_equal ['salary DESC'], DeveloperOrderedBySalary.scoped.order_values }.join
612 612
     end
613 613
   end
614 614
 
@@ -618,10 +618,10 @@ def test_default_scoping_with_inheritance
618 618
     klass.send :default_scope, {}
619 619
 
620 620
     # Scopes added on children should append to parent scope
621  
-    assert klass.scoped.send(:order_clause).blank?
  621
+    assert klass.scoped.order_values.blank?
622 622
 
623 623
     # Parent should still have the original scope
624  
-    assert_equal 'salary DESC', DeveloperOrderedBySalary.scoped.send(:order_clause)
  624
+    assert_equal ['salary DESC'], DeveloperOrderedBySalary.scoped.order_values
625 625
   end
626 626
 
627 627
   def test_method_scope

0 notes on commit 8bb5274

Please sign in to comment.
Something went wrong with that request. Please try again.