aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb')
-rw-r--r--activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
index eb7ff0581a..923fbd8522 100644
--- a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
+++ b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
@@ -14,7 +14,7 @@ module ActiveRecord
def create(attributes = {})
create_record(attributes) { |record| insert_record(record) }
end
-
+
def create!(attributes = {})
create_record(attributes) { |record| insert_record(record, true) }
end
@@ -80,7 +80,7 @@ module ActiveRecord
end
if @reflection.options[:insert_sql]
- @owner.connection.execute(interpolate_sql(@reflection.options[:insert_sql], record))
+ @owner.connection.insert(interpolate_sql(@reflection.options[:insert_sql], record))
else
columns = @owner.connection.columns(@reflection.options[:join_table], "#{@reflection.options[:join_table]} Columns")
@@ -103,7 +103,7 @@ module ActiveRecord
"INSERT INTO #{@owner.connection.quote_table_name @reflection.options[:join_table]} (#{@owner.send(:quoted_column_names, attributes).join(', ')}) " +
"VALUES (#{attributes.values.join(', ')})"
- @owner.connection.execute(sql)
+ @owner.connection.insert(sql)
end
return true
@@ -111,11 +111,11 @@ module ActiveRecord
def delete_records(records)
if sql = @reflection.options[:delete_sql]
- records.each { |record| @owner.connection.execute(interpolate_sql(sql, record)) }
+ records.each { |record| @owner.connection.delete(interpolate_sql(sql, record)) }
else
ids = quoted_record_ids(records)
sql = "DELETE FROM #{@owner.connection.quote_table_name @reflection.options[:join_table]} WHERE #{@reflection.primary_key_name} = #{@owner.quoted_id} AND #{@reflection.association_foreign_key} IN (#{ids})"
- @owner.connection.execute(sql)
+ @owner.connection.delete(sql)
end
end