diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-05-19 17:23:28 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-05-19 17:23:28 +0000 |
commit | 47dcc5ffc68e569cad48ac18a739f24511fff0ab (patch) | |
tree | 95c8319a9690a92d7dbd2c732130880baebdd7a3 /activerecord | |
parent | 9b1fefbf542d09ecfc1c2d0101486250fe40b43c (diff) | |
download | rails-47dcc5ffc68e569cad48ac18a739f24511fff0ab.tar.gz rails-47dcc5ffc68e569cad48ac18a739f24511fff0ab.tar.bz2 rails-47dcc5ffc68e569cad48ac18a739f24511fff0ab.zip |
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
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 2 | ||||
-rw-r--r-- | activerecord/test/finder_test.rb | 8 |
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) |