Module: ROM::SQL::Postgres::Commands::Create

Includes:
Core
Defined in:
lib/rom/sql/extensions/postgres/commands.rb

Instance Method Summary collapse

Instance Method Details

#insert(tuples) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Executes insert statement and returns inserted tuples



30
31
32
33
34
35
36
# File 'lib/rom/sql/extensions/postgres/commands.rb', line 30

def insert(tuples)
  dataset = tuples.flat_map do |tuple|
    returning_dataset.insert(tuple)
  end

  wrap_dataset(dataset)
end

#multi_insert(tuples) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Executes multi_insert statement and returns inserted tuples



41
42
43
# File 'lib/rom/sql/extensions/postgres/commands.rb', line 41

def multi_insert(tuples)
  returning_dataset.multi_insert(tuples)
end

#upsert(tuple, opts = EMPTY_HASH) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Executes upsert statement (INSERT with ON CONFLICT clause) and returns inserted/updated tuples



49
50
51
# File 'lib/rom/sql/extensions/postgres/commands.rb', line 49

def upsert(tuple, opts = EMPTY_HASH)
  returning_dataset.insert_conflict(opts).insert(tuple)
end