struct CQL::ActiveRecord::BulkInsert

Overview

Multi-row INSERT behind Model.insert_all and Model.upsert_all. Every row is checked before the first statement, and a run of several batches commits or rolls back as a whole.

Defined in:

active_record/bulk_insert.cr

Constant Summary

TIMESTAMP_COLUMNS = {:created_at, :updated_at}

Constructors

Instance Method Summary

Constructor Detail

def self.new(schema : CQL::Schema, table : Symbol, rows : Array(Row), generate_id : -> DB::Any | Nil = nil, conflict : Conflict | Nil = nil, primary_key : Symbol = :id) #

generate_id fills a missing or nil primary_key (UUID and ULID keys); without it a nil key is dropped so the database assigns one.


[View source]

Instance Method Detail

def call(batch_size : Int32 | Nil = nil) : Int64 #

Inserts the rows, batch_size per statement (by default as many as the dialect's bind-parameter limit allows), and returns the number of rows inserted.


[View source]
def first_statement(batch_size : Int32 | Nil = nil) : CQL::Insert | Nil #

The statement #call sends for the first batch, checked and built but not run.


[View source]