mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
096e25bce7
MySQL don't support conflict target on insert_all so we can't pass the :unique_by option. But, if you don't check if the index exists MySQL will successfully inset the data. If there is a conflict in an index like the primary key the database will raise an error. We should let the database decide if the data is acceptable or not. The test added on this commit exercise a table that has composite primary keys, but, in order to keep all the Rails behavior working (given Rails doesn't officially support composite primary keys) we set the primary key to an auto increment :id column.
5 lines
92 B
Ruby
5 lines
92 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Cart < ActiveRecord::Base
|
|
self.primary_key = :id
|
|
end
|