Skip to content
Browse files

Update lingering uses of deprecated association dependency options (c…

…loses #4169) [coffe2code]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3941 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 6c67905 commit e18fad6c438200e147b0574cb30078d6a987a116 @dhh dhh committed Mar 18, 2006
View
2 activerecord/lib/active_record/associations.rb
@@ -271,7 +271,7 @@ module ClassMethods
# * <tt>collection=objects</tt> - replaces the collections content by deleting and adding objects as appropriate.
# * <tt>collection_singular_ids=ids</tt> - replace the collection by the objects identified by the primary keys in +ids+
# * <tt>collection.clear</tt> - removes every object from the collection. This destroys the associated objects if they
- # are <tt>:dependent</tt>, deletes them directly from the database if they are <tt>:exclusively_dependent</tt>,
+ # are <tt>:dependent</tt>, deletes them directly from the database if they are <tt>:dependent => :delete_all</tt>,
# and sets their foreign keys to NULL otherwise.
# * <tt>collection.empty?</tt> - returns true if there are no associated objects.
# * <tt>collection.size</tt> - returns the number of associated objects.
View
2 activerecord/lib/active_record/associations/association_collection.rb
@@ -62,7 +62,7 @@ def delete(*records)
def clear
return self if length.zero? # forces load_target if hasn't happened already
- if @reflection.options[:exclusively_dependent]
+ if @reflection.options[:dependent] && @reflection.options[:dependent] == :delete_all
destroy_all
else
delete_all
View
8 activerecord/test/fixtures/company.rb
@@ -9,13 +9,13 @@ class Company < ActiveRecord::Base
class Firm < Company
- has_many :clients, :order => "id", :dependent => true, :counter_sql =>
+ has_many :clients, :order => "id", :dependent => :destroy, :counter_sql =>
"SELECT COUNT(*) FROM companies WHERE firm_id = 1 " +
"AND (#{QUOTED_TYPE} = 'Client' OR #{QUOTED_TYPE} = 'SpecialClient' OR #{QUOTED_TYPE} = 'VerySpecialClient' )"
has_many :clients_sorted_desc, :class_name => "Client", :order => "id DESC"
has_many :clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id"
- has_many :dependent_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => true
- has_many :exclusively_dependent_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :exclusively_dependent => true
+ has_many :dependent_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :destroy
+ has_many :exclusively_dependent_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all
has_many :limited_clients, :class_name => "Client", :order => "id", :limit => 1
has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id"
has_many :clients_using_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}'
@@ -29,7 +29,7 @@ class Firm < Company
:finder_sql => 'SELECT * FROM companies WHERE client_of = 1000',
:counter_sql => 'SELECT COUNT(*) FROM companies WHERE client_of = 1000'
- has_one :account, :foreign_key => "firm_id", :dependent => true
+ has_one :account, :foreign_key => "firm_id", :dependent => :destroy
end
class DependentFirm < Company
View
4 activerecord/test/fixtures/company_in_module.rb
@@ -5,13 +5,13 @@ class Company < ActiveRecord::Base
end
class Firm < Company
- has_many :clients, :order => "id", :dependent => true
+ has_many :clients, :order => "id", :dependent => :destroy
has_many :clients_sorted_desc, :class_name => "Client", :order => "id DESC"
has_many :clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id"
has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id"
has_many :clients_using_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}'
- has_one :account, :dependent => true
+ has_one :account, :dependent => :destroy
end
class Client < Company
View
2 activerecord/test/fixtures/reply.rb
@@ -2,7 +2,7 @@
class Reply < Topic
belongs_to :topic, :foreign_key => "parent_id", :counter_cache => true
- has_many :replies, :class_name => "SillyReply", :dependent => true, :foreign_key => "parent_id"
+ has_many :replies, :class_name => "SillyReply", :dependent => :destroy, :foreign_key => "parent_id"
validate :errors_on_empty_content
validate_on_create :title_is_wrong_create
View
2 activerecord/test/fixtures/topic.rb
@@ -1,5 +1,5 @@
class Topic < ActiveRecord::Base
- has_many :replies, :dependent => true, :foreign_key => "parent_id"
+ has_many :replies, :dependent => :destroy, :foreign_key => "parent_id"
serialize :content
before_create :default_written_on
View
4 activerecord/test/reflection_test.rb
@@ -77,7 +77,7 @@ def test_aggregation_reflection
end
def test_has_many_reflection
- reflection_for_clients = ActiveRecord::Reflection::AssociationReflection.new(:has_many, :clients, { :order => "id", :dependent => true }, Firm)
+ reflection_for_clients = ActiveRecord::Reflection::AssociationReflection.new(:has_many, :clients, { :order => "id", :dependent => :destroy }, Firm)
assert_equal reflection_for_clients, Firm.reflect_on_association(:clients)
@@ -89,7 +89,7 @@ def test_has_many_reflection
end
def test_has_one_reflection
- reflection_for_account = ActiveRecord::Reflection::AssociationReflection.new(:has_one, :account, { :foreign_key => "firm_id", :dependent => true }, Firm)
+ reflection_for_account = ActiveRecord::Reflection::AssociationReflection.new(:has_one, :account, { :foreign_key => "firm_id", :dependent => :destroy }, Firm)
assert_equal reflection_for_account, Firm.reflect_on_association(:account)
assert_equal Account, Firm.reflect_on_association(:account).klass

0 comments on commit e18fad6

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