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

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

Overview

SQL create command

Direct Known Subclasses

Postgres::Commands::Upsert

Instance Method Summary collapse

Instance Method Details

#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