Class: ROM::SQL::Commands::Create

Inherits:
Commands::Create
  • Object
show all
Includes:
ErrorWrapper, Transaction
Defined in:
lib/rom/sql/commands/create.rb

Overview

SQL create command

Direct Known Subclasses

Postgres::Upsert

Instance Method Summary collapse

Instance Method Details

#call(*args) ⇒ Object Also known as: [] Originally defined in module ErrorWrapper

Handle Sequel errors and re-raise ROM-specific errors

#execute(tuples) ⇒ Object

Inserts provided tuples into the database table



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rom/sql/commands/create.rb', line 24

def execute(tuples)
  insert_tuples = with_input_tuples(tuples) do |tuple|
    attributes = input[tuple]
    attributes.to_h
  end

  if insert_tuples.length > 1
    multi_insert(insert_tuples)
  else
    insert(insert_tuples)
  end
end

#transaction(options = {}, &block) ⇒ ROM::Commands::Result::Success, ROM::Commands::Result::Failure Originally defined in module Transaction

Start a transaction

Parameters:

  • options (Hash) (defaults to: {})

    The options hash supported by Sequel

Returns:

  • (ROM::Commands::Result::Success, ROM::Commands::Result::Failure)