aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorheavysixer <heavysixer@gmail.com>2008-10-25 13:33:39 -0500
committerheavysixer <heavysixer@gmail.com>2008-10-25 13:33:39 -0500
commit14f05140e53f4f58bc86ee08b9a4ba836c14f9be (patch)
tree03b975c55bb42b964edc8a3507f63f92487a42ed /activerecord
parent35f29f7ea5ba183e49e26367cc31649ff4bd0e97 (diff)
parent650aa015789c704ca8ea864f1117faf3f404a59b (diff)
downloadrails-14f05140e53f4f58bc86ee08b9a4ba836c14f9be.tar.gz
rails-14f05140e53f4f58bc86ee08b9a4ba836c14f9be.tar.bz2
rails-14f05140e53f4f58bc86ee08b9a4ba836c14f9be.zip
Merge branch 'master' of git@github.com:lifo/docrails
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG4
-rw-r--r--activerecord/Rakefile6
-rwxr-xr-xactiverecord/lib/active_record/associations.rb2
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb7
4 files changed, 14 insertions, 5 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 6479cc5a9b..fec110d569 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,4 +1,6 @@
-*Edge*
+*2.2.0 [RC1] (October 24th, 2008)*
+
+* Skip collection ids reader optimization if using :finder_sql [Jeremy Kemper]
* Add Model#delete instance method, similar to Model.delete class method. #1086 [Hongli Lai]
diff --git a/activerecord/Rakefile b/activerecord/Rakefile
index 983528aff7..f192646547 100644
--- a/activerecord/Rakefile
+++ b/activerecord/Rakefile
@@ -171,7 +171,7 @@ spec = Gem::Specification.new do |s|
s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
end
- s.add_dependency('activesupport', '= 2.1.0' + PKG_BUILD)
+ s.add_dependency('activesupport', '= 2.2.0' + PKG_BUILD)
s.files.delete FIXTURES_ROOT + "/fixture_database.sqlite"
s.files.delete FIXTURES_ROOT + "/fixture_database_2.sqlite"
@@ -225,8 +225,8 @@ end
desc "Publish the beta gem"
task :pgem => [:package] do
- Rake::SshFilePublisher.new("wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
- `ssh wrath.rubyonrails.org './gemupdate.sh'`
+ Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
+ `ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'`
end
desc "Publish the API documentation"
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 187caa13d0..52f6a04da1 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1296,7 +1296,7 @@ module ActiveRecord
end
define_method("#{reflection.name.to_s.singularize}_ids") do
- if send(reflection.name).loaded?
+ if send(reflection.name).loaded? || reflection.options[:finder_sql]
send(reflection.name).map(&:id)
else
send(reflection.name).all(:select => "#{reflection.quoted_table_name}.#{reflection.klass.primary_key}").map(&:id)
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index 8d97b30c74..59784e1bcb 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -853,6 +853,13 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert !company.clients.loaded?
end
+ def test_get_ids_for_unloaded_finder_sql_associations_loads_them
+ company = companies(:first_firm)
+ assert !company.clients_using_sql.loaded?
+ assert_equal [companies(:second_client).id], company.clients_using_sql_ids
+ assert company.clients_using_sql.loaded?
+ end
+
def test_assign_ids
firm = Firm.new("name" => "Apple")
firm.client_ids = [companies(:first_client).id, companies(:second_client).id]