public
Fork of rails/rails
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/johngibbs/rails.git
DRY associations code and improve eager loading tests.
lifo (author)
Thu May 15 05:41:54 -0700 2008
commit  802034ff5f1c3e3b576b664d5660e76c8f44909d
tree    9bb32bab53553ec3f06b2b80e71d60b522abc6e5
parent  b28b54cab090bed8f099ef375b419a8f92390dd4
...
1451
1452
1453
1454
1455
1456
1457
1458
1459
...
1507
1508
1509
1510
1511
1512
1513
1514
1515
 
 
1516
1517
1518
1519
1520
1521
1522
1523
1524
 
 
1525
1526
1527
1528
1529
1530
1531
1532
 
1533
1534
1535
...
1451
1452
1453
 
 
 
1454
1455
1456
...
1504
1505
1506
 
 
 
 
 
 
1507
1508
1509
1510
1511
 
 
 
 
 
 
1512
1513
1514
1515
1516
 
 
 
 
 
1517
1518
1519
1520
0
@@ -1451,9 +1451,6 @@ module ActiveRecord
0
             join_dependency.joins_for_table_name(table)
0
           }.flatten.compact.uniq
0
 
0
-
0
-
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
@@ -1507,29 +1504,17 @@ module ActiveRecord
0
         end
0
 
0
         # Checks if the conditions reference a table other than the current model table
0
- def include_eager_conditions?(options,tables = nil)
0
- tables = conditions_tables(options)
0
- return false unless tables.any?
0
- tables.any? do |condition_table_name|
0
- condition_table_name != table_name
0
- end
0
+ def include_eager_conditions?(options, tables = nil)
0
+ ((tables || conditions_tables(options)) - [table_name]).any?
0
         end
0
 
0
         # Checks if the query order references a table other than the current model's table.
0
- def include_eager_order?(options,tables = nil)
0
- tables = order_tables(options)
0
- return false unless tables.any?
0
- tables.any? do |order_table_name|
0
- order_table_name != table_name
0
- end
0
+ def include_eager_order?(options, tables = nil)
0
+ ((tables || order_tables(options)) - [table_name]).any?
0
         end
0
 
0
         def include_eager_select?(options)
0
- selects = selects_tables(options)
0
- return false unless selects.any?
0
- selects.any? do |select|
0
- select != table_name
0
- end
0
+ (selects_tables(options) - [table_name]).any?
0
         end
0
 
0
         def references_eager_loaded_tables?(options)
...
9
10
11
 
12
13
14
...
866
867
868
869
 
 
 
870
871
872
...
9
10
11
12
13
14
15
...
867
868
869
 
870
871
872
873
874
875
0
@@ -9,6 +9,7 @@ require 'models/developer'
0
 require 'models/post'
0
 require 'models/customer'
0
 require 'models/job'
0
+require 'models/categorization'
0
 
0
 class FinderTest < ActiveRecord::TestCase
0
   fixtures :companies, :topics, :entrants, :developers, :developers_projects, :posts, :comments, :accounts, :authors, :customers
0
@@ -866,7 +867,9 @@ class FinderTest < ActiveRecord::TestCase
0
   end
0
 
0
   def test_with_limiting_with_custom_select
0
- assert_equal 3, Post.find(:all, :include => :author, :select => ' posts.*, authors.id as "author_id"', :limit => 3).size
0
+ posts = Post.find(:all, :include => :author, :select => ' posts.*, authors.id as "author_id"', :limit => 3)
0
+ assert_equal 3, posts.size
0
+ assert_equal [0, 1, 1], posts.map(&:author_id).sort
0
   end
0
 
0
   protected

Comments

    No one has commented yet.