aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/CHANGELOG2
-rwxr-xr-xactiverecord/lib/active_record/base.rb2
-rw-r--r--activerecord/test/finder_test.rb8
3 files changed, 11 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 58a57ea4b1..ee34dab6f8 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fixed use of construct_finder_sql when using :join #1288 [dwlt@dwlt.net]
+
* Fixed that :delete_sql in has_and_belongs_to_many associations couldn't access record properties #1299 [Rick Olson]
* Fixed that clone would break when an aggregate had the same name as one of its attributes #1307 [bitsweat]
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 37c3ca0e07..49d6a0c7d6 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -736,7 +736,7 @@ module ActiveRecord #:nodoc:
def construct_finder_sql(options)
sql = "SELECT * FROM #{table_name} "
- sql << "#{options[:joins]} " if options[:joins]
+ sql << ", #{options[:joins]} " if options[:joins]
add_conditions!(sql, options[:conditions])
sql << "ORDER BY #{options[:order]} " if options[:order]
add_limit!(sql, options)
diff --git a/activerecord/test/finder_test.rb b/activerecord/test/finder_test.rb
index 3748e26f5e..88e8f14cf9 100644
--- a/activerecord/test/finder_test.rb
+++ b/activerecord/test/finder_test.rb
@@ -276,6 +276,14 @@ class FinderTest < Test::Unit::TestCase
assert_equal 'fixture_9', last_two_developers.first.name
end
+ def test_find_all_with_join
+ developers_on_project_one = Developer.find :all, :joins => 'developers_projects', :conditions => 'id=developer_id AND project_id=1'
+
+ assert_equal 2, developers_on_project_one.length
+ assert_equal 'David', developers_on_project_one.first.name
+ assert_equal 'Jamis', developers_on_project_one.last.name
+ end
+
protected
def bind(statement, *vars)
if vars.first.is_a?(Hash)