From d56d3251990ae6e35632c8cba0a6f8604b47fdd9 Mon Sep 17 00:00:00 2001 From: Peter Wagenet Date: Wed, 2 Jul 2008 21:27:42 -0400 Subject: [PATCH] Rejected numbers returned by *_tables methods --- activerecord/lib/active_record/associations.rb | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index d43e07a..570ccf9 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1523,19 +1523,19 @@ module ActiveRecord else all << cond end end - conditions.join(' ').scan(/([\.\w]+).?\./).flatten + conditions.join(' ').scan(/([\.\w]+).?\./).flatten.reject{|t| t.match(/^\d+$/) } end def order_tables(options) order = [options[:order], scope(:find, :order) ].join(", ") return [] unless order && order.is_a?(String) - order.scan(/([\.\w]+).?\./).flatten + order.scan(/([\.\w]+).?\./).flatten.reject{|t| t.match(/^\d+$/) } end def selects_tables(options) select = options[:select] return [] unless select && select.is_a?(String) - select.scan(/"?([\.\w]+)"?.?\./).flatten + select.scan(/"?([\.\w]+)"?.?\./).flatten.reject{|t| t.match(/^\d+$/) } end # Checks if the conditions reference a table other than the current model table -- 1.5.5 From c87984c0f65b84a47bd0c42573ff06a9598759d7 Mon Sep 17 00:00:00 2001 From: Peter Wagenet Date: Mon, 14 Jul 2008 12:06:21 -0400 Subject: [PATCH] Tests --- activerecord/test/cases/associations/eager_test.rb | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index f65ada5..d275c8c 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -559,6 +559,13 @@ class EagerAssociationTest < ActiveRecord::TestCase assert_nothing_raised { Post.find(:all, :include => 'comments') } end + def test_eager_with_floating_point_numbers + assert_queries(2) do + # Before changes, the floating point numbers will be interpreted as table names and will cause this to run in one query + Comment.find :all, :conditions => "123.456 = 123.456", :include => :post + end + end + def test_preconfigured_includes_with_belongs_to author = posts(:welcome).author_with_posts assert_no_queries {assert_equal 5, author.posts.size} -- 1.5.5