Module: ROM::SQL::Postgres::Commands::Create
- Defined in:
- lib/rom/sql/extensions/postgres/commands.rb
Instance Method Summary collapse
-
#insert(tuples) ⇒ Object
private
Executes insert statement and returns inserted tuples.
-
#multi_insert(tuples) ⇒ Object
private
Executes multi_insert statement and returns inserted tuples.
-
#upsert(tuple, opts = EMPTY_HASH) ⇒ Object
private
Executes upsert statement (INSERT with ON CONFLICT clause) and returns inserted/updated tuples.
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 17 18 |
# File 'lib/rom/sql/extensions/postgres/commands.rb', line 12 def insert(tuples) dataset = tuples.map do |tuple| relation.dataset.returning.insert(tuple) end.flatten(1) 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
23 24 25 |
# File 'lib/rom/sql/extensions/postgres/commands.rb', line 23 def multi_insert(tuples) relation.dataset.returning.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
31 32 33 |
# File 'lib/rom/sql/extensions/postgres/commands.rb', line 31 def upsert(tuple, opts = EMPTY_HASH) relation.dataset.returning.insert_conflict(opts).insert(tuple) end |