module CQL::ActiveRecord::Insertable

Overview

Insertable module provides create! methods for ActiveRecord models.

UUID/ULID Generation in Transactions

Important Note: UUIDs and ULIDs are generated client-side BEFORE the INSERT statement is executed. This design ensures cross-database compatibility (SQLite, PostgreSQL, MySQL) by storing these IDs as strings.

Transaction Behavior:

Example with transactions (for a model with a UUID key):

User.transaction do |tx|
  User.create!(name: "Alice", email: "alice@example.com") # UUID generated here
  tx.rollback                                             # UUID is "wasted" but harmless
end

Defined in:

active_record/insertable.cr