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

Defined in:
lib/rom/sql/commands_ext/postgres.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



12
13
14
15
16
# File 'lib/rom/sql/commands_ext/postgres.rb', line 12

def insert(tuples)
  tuples.map do |tuple|
    relation.dataset.returning(*relation.columns).insert(tuple)
  end.flatten
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



21
22
23
# File 'lib/rom/sql/commands_ext/postgres.rb', line 21

def multi_insert(tuples)
  relation.dataset.returning(*relation.columns).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



29
30
31
# File 'lib/rom/sql/commands_ext/postgres.rb', line 29

def upsert(tuple, opts = EMPTY_HASH)
  relation.dataset.returning(*relation.columns).insert_conflict(opts).insert(tuple)
end