public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Don't interpret decimals as table names in 
ActiveRecord::Associations::ClassMethods#references_eager_loaded_tables? [#532 
state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
rxcfc (author)
Wed Jul 02 18:27:42 -0700 2008
lifo (committer)
Thu Aug 21 09:21:17 -0700 2008
commit  8622787f8748434b4ceb2b925a35b17a38e1f2d6
tree    421b5424d77319f99a015b9658f447196d73a8c2
parent  3724dafe71f4afb2ca9f4d7d2526b228aa6c05a3
...
1679
1680
1681
1682
 
1683
1684
1685
1686
1687
1688
 
1689
1690
1691
1692
1693
1694
 
1695
1696
1697
...
1679
1680
1681
 
1682
1683
1684
1685
1686
1687
 
1688
1689
1690
1691
1692
1693
 
1694
1695
1696
1697
0
@@ -1679,19 +1679,19 @@ module ActiveRecord
0
               else            all << cond
0
             end
0
           end
0
-          conditions.join(' ').scan(/([\.\w]+).?\./).flatten
0
+          conditions.join(' ').scan(/([\.a-zA-Z_]+).?\./).flatten
0
         end
0
 
0
         def order_tables(options)
0
           order = [options[:order], scope(:find, :order) ].join(", ")
0
           return [] unless order && order.is_a?(String)
0
-          order.scan(/([\.\w]+).?\./).flatten
0
+          order.scan(/([\.a-zA-Z_]+).?\./).flatten
0
         end
0
 
0
         def selects_tables(options)
0
           select = options[:select]
0
           return [] unless select && select.is_a?(String)
0
-          select.scan(/"?([\.\w]+)"?.?\./).flatten
0
+          select.scan(/"?([\.a-zA-Z_]+)"?.?\./).flatten
0
         end
0
 
0
         # Checks if the conditions reference a table other than the current model table
...
559
560
561
 
 
 
 
 
 
 
562
563
564
...
559
560
561
562
563
564
565
566
567
568
569
570
571
0
@@ -559,6 +559,13 @@ class EagerAssociationTest < ActiveRecord::TestCase
0
     assert_nothing_raised { Post.find(:all, :include => 'comments') }
0
   end
0
 
0
+  def test_eager_with_floating_point_numbers
0
+    assert_queries(2) do
0
+      # Before changes, the floating point numbers will be interpreted as table names and will cause this to run in one query
0
+      Comment.find :all, :conditions => "123.456 = 123.456", :include => :post
0
+    end
0
+  end
0
+
0
   def test_preconfigured_includes_with_belongs_to
0
     author = posts(:welcome).author_with_posts
0
     assert_no_queries {assert_equal 5, author.posts.size}

Comments