Class: ROM::SQL::Commands::Create
- Inherits:
-
Commands::Create
- Object
- Commands::Create
- ROM::SQL::Commands::Create
- Includes:
- ErrorWrapper, Transaction
- Defined in:
- lib/rom/sql/commands/create.rb
Overview
SQL create command
Direct Known Subclasses
Instance Method Summary collapse
-
#call(*args) ⇒ Object
(also: #[])
included
from ErrorWrapper
Handle Sequel errors and re-raise ROM-specific errors.
-
#execute(tuples) ⇒ Object
Inserts provided tuples into the database table.
-
#transaction(options = {}, &block) ⇒ ROM::Commands::Result::Success, ROM::Commands::Result::Failure
included
from Transaction
Start a transaction.
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