Rails 7 adds new options to upsert_all
13-Jan-2022 2218
If we check the source code of upsert_all, we understand that it calls execute method of InsertAll under the hood which later updates or inserts (upserts) multiple records into the database using a single SQL INSERT statement.For Postgres and SQlite3 upsert_all utilizes ON CONFLICT clause, whereas for MySQL it uses ON DUPLICATE KEY clause.Check implementation of build_insert_sql method under postgresql_adapter.rb, sqlite3_adapter.rb and abstract_mysql_adapter.rb to get further details.In this article, we will first see the available options with upsert_all in Rails 6, and then the newly introduced ones in Rails 7.
Rails 7 adds new options to upsert_all #ruby #rubydeveloper #rubyonrails #Rails #options #upsert_all https://rubyonrails.ba/link/rails-7-adds-new-options-to-upsert_all