Changeset 2939
- Timestamp:
- 11/08/05 08:41:34 (3 years ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/associations.rb (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r2935 r2939 1 1 *SVN* 2 3 * Deprecate the old, confusing :exclusively_dependent option in favor of :dependent => :delete_all. [Jeremy Kemper] 2 4 3 5 * More compatible Oracle column reflection. #2771 [Ryan Davis <ryand-ruby@zenspider.com>, Michael Schoen <schoenm@earthlink.net>] trunk/activerecord/lib/active_record/associations.rb
r2898 r2939 312 312 # as the default foreign_key. 313 313 # * <tt>:dependent</tt> - if set to :destroy (or true) all the associated objects are destroyed 314 # alongside this object. Also accepts :nullify which will set the associated object's foreign key 315 # field to NULL. 314 # alongside this object by calling their destroy method. If set to :delete_all all associated 315 # objects are deleted *without* calling their destroy method. If set to :nullify all associated 316 # objects' foreign keys are set to NULL *without* calling their save callbacks. 316 317 # May not be set if :exclusively_dependent is also set. 317 # * <tt>:exclusively_dependent</tt> - if set to true all the associated object are deleted in one SQL statement without having their 318 # * <tt>:exclusively_dependent</tt> - Deprecated; equivalent to :dependent => :delete_all. If set to true all 319 # the associated object are deleted in one SQL statement without having their 318 320 # before_destroy callback run. This should only be used on associations that depend solely on this class and don't need to do any 319 321 # clean-up in before_destroy. The upside is that it's much faster, especially if there's a counter_cache involved. … … 351 353 352 354 raise ArgumentError, ':dependent and :exclusively_dependent are mutually exclusive options. You may specify one or the other.' if options[:dependent] and options[:exclusively_dependent] 353 355 356 if options[:exclusively_dependent] 357 options[:dependent] = :delete_all 358 #warn "The :exclusively_dependent option is deprecated. Please use :dependent => :delete_all instead.") 359 end 360 354 361 # See HasManyAssociation#delete_records. Dependent associations 355 362 # delete children, otherwise foreign key is set to NULL. … … 357 364 when :destroy, true 358 365 module_eval "before_destroy '#{association_name}.each { |o| o.destroy }'" 366 when :delete_all 367 module_eval "before_destroy { |record| #{association_class_name}.delete_all(%(#{association_class_primary_key_name} = \#{record.quoted_id})) }" 359 368 when :nullify 360 369 module_eval "before_destroy { |record| #{association_class_name}.update_all(%(#{association_class_primary_key_name} = NULL), %(#{association_class_primary_key_name} = \#{record.quoted_id})) }" … … 362 371 # pass 363 372 else 364 raise ArgumentError, 'The :dependent option expects either true, :destroy or :nullify' 365 end 366 367 if options[:exclusively_dependent] 368 module_eval "before_destroy { |record| #{association_class_name}.delete_all(%(#{association_class_primary_key_name} = \#{record.quoted_id})) }" 369 end 373 raise ArgumentError, 'The :dependent option expects either true, :destroy, :delete_all, or :nullify' 374 end 375 370 376 371 377 add_multiple_associated_save_callbacks(association_name)