Skip to content
This repository
Browse code

Fixed use of construct_finder_sql when using :join #1288 [dwlt@dwlt.net]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1316 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 47dcc5ffc68e569cad48ac18a739f24511fff0ab 1 parent 9b1fefb
David Heinemeier Hansson authored May 19, 2005
2  activerecord/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *SVN*
2 2
 
  3
+* Fixed use of construct_finder_sql when using :join #1288 [dwlt@dwlt.net]
  4
+
3 5
 * Fixed that :delete_sql in has_and_belongs_to_many associations couldn't access record properties #1299 [Rick Olson]
4 6
 
5 7
 * Fixed that clone would break when an aggregate had the same name as one of its attributes #1307 [bitsweat]
2  activerecord/lib/active_record/base.rb
@@ -736,7 +736,7 @@ def type_name_with_module(type_name)
736 736
 
737 737
         def construct_finder_sql(options)
738 738
           sql  = "SELECT * FROM #{table_name} " 
739  
-          sql << "#{options[:joins]} " if options[:joins]
  739
+          sql << ", #{options[:joins]} " if options[:joins]
740 740
           add_conditions!(sql, options[:conditions])
741 741
           sql << "ORDER BY #{options[:order]} " if options[:order]
742 742
           add_limit!(sql, options)
8  activerecord/test/finder_test.rb
@@ -276,6 +276,14 @@ def test_find_all_with_limit_and_offset
276 276
     assert_equal 'fixture_9', last_two_developers.first.name
277 277
   end
278 278
 
  279
+  def test_find_all_with_join
  280
+    developers_on_project_one = Developer.find :all, :joins => 'developers_projects', :conditions => 'id=developer_id AND project_id=1'
  281
+    
  282
+    assert_equal 2, developers_on_project_one.length
  283
+    assert_equal 'David', developers_on_project_one.first.name
  284
+    assert_equal 'Jamis', developers_on_project_one.last.name
  285
+  end
  286
+
279 287
   protected
280 288
     def bind(statement, *vars)
281 289
       if vars.first.is_a?(Hash)

0 notes on commit 47dcc5f

Please sign in to comment.
Something went wrong with that request. Please try again.