aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-02-20 22:27:22 +0900
committerGitHub <noreply@github.com>2019-02-20 22:27:22 +0900
commitceed0aa2e0e45523496130e5a5c4a4f032e8cd2a (patch)
tree09b1dfbb51826921f83ffbeede9ddfbd295af267 /activerecord
parentdf2ebf9b59b8ef063923136ba7097328db6c949f (diff)
parent11c34d8ef44b95b3989cb8376af09842293c892c (diff)
downloadrails-ceed0aa2e0e45523496130e5a5c4a4f032e8cd2a.tar.gz
rails-ceed0aa2e0e45523496130e5a5c4a4f032e8cd2a.tar.bz2
rails-ceed0aa2e0e45523496130e5a5c4a4f032e8cd2a.zip
Merge pull request #35327 from abhaynikam/use-delete-by-and-destroy-by-method
Replaced usage of where.delete/destroy_all with delete/destroy_by
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/callbacks.rb2
-rw-r--r--activerecord/lib/active_record/migration.rb2
-rw-r--r--activerecord/lib/active_record/persistence.rb2
-rw-r--r--activerecord/test/models/topic.rb2
4 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb
index 5407af85ea..6b927e9797 100644
--- a/activerecord/lib/active_record/callbacks.rb
+++ b/activerecord/lib/active_record/callbacks.rb
@@ -95,7 +95,7 @@ module ActiveRecord
#
# private
# def delete_parents
- # self.class.where(parent_id: id).delete_all
+ # self.class.delete_by(parent_id: id)
# end
# end
#
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb
index 4b2e9ed81c..c20274420f 100644
--- a/activerecord/lib/active_record/migration.rb
+++ b/activerecord/lib/active_record/migration.rb
@@ -1323,7 +1323,7 @@ module ActiveRecord
def record_version_state_after_migrating(version)
if down?
migrated.delete(version)
- ActiveRecord::SchemaMigration.where(version: version.to_s).delete_all
+ ActiveRecord::SchemaMigration.delete_by(version: version.to_s)
else
migrated << version
ActiveRecord::SchemaMigration.create!(version: version.to_s)
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index 510a275b4e..7763496519 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -161,7 +161,7 @@ module ActiveRecord
# # Delete multiple rows
# Todo.delete([2,3,4])
def delete(id_or_array)
- where(primary_key => id_or_array).delete_all
+ delete_by(primary_key => id_or_array)
end
def _insert_record(values) # :nodoc:
diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb
index 75890c327a..0c8880a20e 100644
--- a/activerecord/test/models/topic.rb
+++ b/activerecord/test/models/topic.rb
@@ -99,7 +99,7 @@ class Topic < ActiveRecord::Base
end
def destroy_children
- self.class.where("parent_id = #{id}").delete_all
+ self.class.delete_by(parent_id: id)
end
def set_email_address