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



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

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



39
40
41
# File 'lib/rom/sql/extensions/postgres/commands.rb', line 39

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



47
48
49
# File 'lib/rom/sql/extensions/postgres/commands.rb', line 47

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