Rails 7 adds new options to upsert_all

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 https://rubyonrails.ba/single/rails-7-adds-new-options-to-upsert_all

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles