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 (author)
Mon Jul 14 19:17:06 -0700 2008
jeremy (committer)
Tue Jul 15 15:54:20 -0700 2008
commit  aa99bd19e187650eae5e7031176997f7215041bd
tree    1c9d5fced846d5989cbf8716886656c51adaecf1
parent  84baada079fa7e68750c1e386f9849d2d47b59e1
...
1478
1479
1480
 
 
 
 
 
1481
1482
1483
1484
 
1485
1486
1487
...
1495
1496
1497
1498
1499
 
 
1500
1501
1502
...
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
 
1489
1490
1491
1492
...
1500
1501
1502
 
 
1503
1504
1505
1506
1507
0
@@ -1478,10 +1478,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
@@ -1495,8 +1500,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

    No one has commented yet.