mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #35531 from boblail/issue-35519
Update documentation on upsert_all so that it is correct for Postgres [ci skip]
This commit is contained in:
commit
9175a44532
1 changed files with 7 additions and 3 deletions
|
@ -243,11 +243,15 @@ module ActiveRecord
|
||||||
#
|
#
|
||||||
# ==== Examples
|
# ==== 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)
|
# # ('Eloquent Ruby' will overwrite 'Rework' because its ISBN is duplicate)
|
||||||
# Book.upsert_all([
|
# 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 ] })
|
# unique_by: { columns: %w[ isbn ] })
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue