public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Fixed postgresql limited eager loading for the case where scoped :order was 
present
Tarmo Tänav (author)
Mon Jul 14 19:17:06 -0700 2008
jeremy (committer)
Mon Jul 14 22:44:58 -0700 2008
commit  8c91b767c0f36e9d767eb230ec42b111e57d90da
tree    a7fdfc72ea67d2992e5776703efaf87a16b49a07
parent  34510456585216004e483b79beeea3ddc3eb4de6
...
1486
1487
1488
 
 
 
 
 
1489
1490
1491
1492
 
1493
1494
1495
...
1503
1504
1505
1506
1507
 
 
1508
1509
1510
...
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
 
1497
1498
1499
1500
...
1508
1509
1510
 
 
1511
1512
1513
1514
1515
0
@@ -1486,10 +1486,15 @@ module ActiveRecord
0
             join_dependency.joins_for_table_name(table)
0
           }.flatten.compact.uniq
0
 
0
+          order = options[:order]
0
+          if scoped_order = (scope && scope[:order])
0
+            order = order ? "#{order}, #{scoped_order}" : scoped_order
0
+          end
0
+
0
           is_distinct = !options[:joins].blank? || include_eager_conditions?(options, tables_from_conditions) || include_eager_order?(options, tables_from_order)
0
           sql = "SELECT "
0
           if is_distinct
0
-            sql << connection.distinct("#{connection.quote_table_name table_name}.#{primary_key}", options[:order])
0
+            sql << connection.distinct("#{connection.quote_table_name table_name}.#{primary_key}", order)
0
           else
0
             sql << primary_key
0
           end
0
@@ -1503,8 +1508,8 @@ module ActiveRecord
0
           add_conditions!(sql, options[:conditions], scope)
0
           add_group!(sql, options[:group], scope)
0
 
0
-          if options[:order] && is_distinct
0
-            connection.add_order_by_for_association_limiting!(sql, options)
0
+          if order && is_distinct
0
+            connection.add_order_by_for_association_limiting!(sql, :order => order)
0
           else
0
             add_order!(sql, options[:order], scope)
0
           end

Comments