diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-02-19 21:47:22 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-02-19 21:52:49 +0900 |
commit | 64ef5e2f9e854a7f988227d629a699f11a998b17 (patch) | |
tree | ef239f8f8df88a6d200c94385f17fdb95681dac9 /activerecord/CHANGELOG.md | |
parent | 30016df82f892f621c4937f3aec397f8d4cb30f2 (diff) | |
parent | 5c8d4c3466cbfa850a89f718ec358ed3a352c34e (diff) | |
download | rails-64ef5e2f9e854a7f988227d629a699f11a998b17.tar.gz rails-64ef5e2f9e854a7f988227d629a699f11a998b17.tar.bz2 rails-64ef5e2f9e854a7f988227d629a699f11a998b17.zip |
Merge pull request #35316 from abhaynikam/35304-add-delete_by_and_destroy_by
Introduce delete_by and destroy_by methods to ActiveRecord::Relation
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r-- | activerecord/CHANGELOG.md | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index c1ce01c312..8f626156a2 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,29 @@ +* Introduce `ActiveRecord::Relation#destroy_by` and `ActiveRecord::Relation#delete_by`. + + `destroy_by` allows relation to find all the records matching the condition and perform + `destroy_all` on the matched records. + + Example: + + Person.destroy_by(name: 'David') + Person.destroy_by(name: 'David', rating: 4) + + david = Person.find_by(name: 'David') + david.posts.destroy_by(id: [1, 2, 3]) + + `delete_by` allows relation to find all the records matching the condition and perform + `delete_all` on the matched records. + + Example: + + Person.delete_by(name: 'David') + Person.delete_by(name: 'David', rating: 4) + + david = Person.find_by(name: 'David') + david.posts.delete_by(id: [1, 2, 3]) + + *Abhay Nikam* + * Don't allow `where` with invalid value matches to nil values. Fixes #33624. |