Module: ROM::SQL::Commands::Postgres::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 |
# File 'lib/rom/sql/extensions/postgres/commands.rb', line 12 def insert(tuples) tuples.map do |tuple| relation.dataset.returning(*relation.columns).insert(tuple) end.flatten(1) 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/extensions/postgres/commands.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/extensions/postgres/commands.rb', line 29 def upsert(tuple, opts = EMPTY_HASH) relation.dataset.returning(*relation.columns).insert_conflict(opts).insert(tuple) end |