aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-03-09 20:50:53 +0900
committerGitHub <noreply@github.com>2019-03-09 20:50:53 +0900
commit9175a4453298b97b6b0b6e144c5a45f94abbdc18 (patch)
treef9064abb9c0579d53e77884d4fa63d9a4bbb73bb /activerecord
parentb7fa01bb2fb14ea96e3274b7a0a03d7ba23eb1bd (diff)
parent02441e8f1726efaa69e2683702652ed343692b6c (diff)
downloadrails-9175a4453298b97b6b0b6e144c5a45f94abbdc18.tar.gz
rails-9175a4453298b97b6b0b6e144c5a45f94abbdc18.tar.bz2
rails-9175a4453298b97b6b0b6e144c5a45f94abbdc18.zip
Merge pull request #35531 from boblail/issue-35519
Update documentation on upsert_all so that it is correct for Postgres [ci skip]
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/persistence.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index ba2ac7908e..29d727477d 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -243,11 +243,15 @@ module ActiveRecord
#
# ==== Examples
#
- # # Insert multiple records, performing an upsert when records have duplicate ISBNs
+ # # Given a Unique Index on books.isbn and the following record:
+ # Book.create!(title: 'Rework', author: 'David', isbn: '1')
+ #
+ # # Insert multiple records, allowing new records with the same ISBN
+ # # as an existing record to overwrite the existing record.
# # ('Eloquent Ruby' will overwrite 'Rework' because its ISBN is duplicate)
# Book.upsert_all([
- # { title: 'Rework', author: 'David', isbn: '1' },
- # { title: 'Eloquent Ruby', author: 'Russ', isbn: '1' }
+ # { title: 'Eloquent Ruby', author: 'Russ', isbn: '1' },
+ # { title: 'Clean Code', author: 'Robert', isbn: '2' }
# ],
# unique_by: { columns: %w[ isbn ] })
#