- Extended by:
- Included in:
- , , , , , ,
- Defined in:
A mixin for ActiveRecord models that enables callers to insert instances of the target class into the database en-bloc via the [bulk_insert] method.
Upon inclusion in the target class, the mixin will perform a number of checks to ensure that the target is eligible for bulk insertions. For instance, it must not use ActiveRecord callbacks that fire between [save]s, since these would not run properly when instances are inserted in bulk.
The mixin uses ActiveRecord 6's [InsertAll] type internally for bulk insertions. Unlike [InsertAll], however, it requires you to pass instances of the target type rather than row hashes, since it will run validations prior to insertion.
Constant Summary collapse
- ALLOWED_CALLBACKS =
These are the callbacks we think safe when used on models that are written to the database in bulk
Set[ :initialize, :validate, :validation, :find, :destroy ].freeze
- DEFAULT_BATCH_SIZE =
- MethodNotAllowedError =
- PrimaryKeySetError =