Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix #delete_all with habtm with :delete_sql

  • Loading branch information...
commit 855fabca669f1a57c70bfa7bfc396495018e4a5c 1 parent b98d1e2
@jonleighton jonleighton authored
View
1  activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
@@ -44,6 +44,7 @@ def count_records
def delete_records(records, method)
if sql = options[:delete_sql]
+ records = load_target if records == :all
records.each { |record| owner.connection.delete(interpolate(sql, record)) }
else
relation = join_table
View
6 activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
@@ -379,6 +379,12 @@ def test_deleting_array_with_sql
assert_equal 0, active_record.developers_by_sql(true).size
end
+ def test_deleting_all_with_sql
+ project = Project.find(1)
+ project.developers_by_sql.delete_all
+ assert_equal 0, project.developers_by_sql.size
+ end
+
def test_deleting_all
david = Developer.find(1)
david.projects.reload
Please sign in to comment.
Something went wrong with that request. Please try again.