Transitional representation for INSERT INTO query.
More...
#include <insert_into.hpp>
|
|
| InsertInto (const Table &tbl) |
| | Starts an INSERT INTO tbl query.
|
| |
| InsertInto | Columns (std::initializer_list< Expr > cols) && |
| | Sets the list of columns to insert into.
|
| |
| InsertInto | Values (std::initializer_list< Expr > vals) && |
| | Sets a single row of values to insert, matching Columns by position.
|
| |
| InsertInto | Rows (std::initializer_list< std::initializer_list< Expr > > rows) && |
| | Sets multiple rows of values to insert, e.g. Rows({{1, 2}, {3, 4}}) for VALUES (1, 2), (3, 4).
|
| |
| InsertInto | Returning (SelectItem item) && |
| | Sets the RETURNING clause to a single entry.
|
| |
| InsertInto | Returning (std::initializer_list< SelectItem > items) && |
| | Sets the RETURNING clause to a comma-separated list of entries.
|
| |
|
InsertInto | OnConflictDoNothing () && |
| | ON CONFLICT DO NOTHING, matching any conflict.
|
| |
| InsertInto | OnConflictDoNothing (std::initializer_list< Expr > target_cols) && |
| | ON CONFLICT (target_cols) DO NOTHING.
|
| |
| InsertInto | OnConflictDoUpdate (std::initializer_list< Expr > target_cols, std::initializer_list< std::pair< Expr, Expr > > assignments) && |
| | ON CONFLICT (target_cols) DO UPDATE SET column = value, .... Reference the row that triggered the conflict via Expr::FromRaw("EXCLUDED.column").
|
| |
| std::string | ToString () const |
| |
Transitional representation for INSERT INTO query.
- See also
- https://www.postgresql.org/docs/current/sql-insert.html
◆ Columns()
| InsertInto iron_query::InsertInto::Columns |
( |
std::initializer_list< Expr > |
cols | ) |
&& |
Sets the list of columns to insert into.
- Exceptions
-
| LogicError | if the column list was already set, or if the count does not match an already-set Values row's arity. |
- Note
- Only the count is checked;
cols are not checked to actually name columns of tbl.
◆ OnConflictDoNothing()
| InsertInto iron_query::InsertInto::OnConflictDoNothing |
( |
std::initializer_list< Expr > |
target_cols | ) |
&& |
ON CONFLICT (target_cols) DO NOTHING.
- Note
- Does not check that
target_cols actually names a unique index/constraint on tbl.
◆ OnConflictDoUpdate()
| InsertInto iron_query::InsertInto::OnConflictDoUpdate |
( |
std::initializer_list< Expr > |
target_cols, |
|
|
std::initializer_list< std::pair< Expr, Expr > > |
assignments |
|
) |
| && |
ON CONFLICT (target_cols) DO UPDATE SET column = value, .... Reference the row that triggered the conflict via Expr::FromRaw("EXCLUDED.column").
- Exceptions
-
- Note
- Does not check that
target_cols actually names a unique index/constraint on tbl, nor that assignments' columns belong to tbl.
◆ Returning() [1/2]
Sets the RETURNING clause to a single entry.
- Exceptions
-
| LogicError | if the RETURNING clause was already set. |
◆ Returning() [2/2]
Sets the RETURNING clause to a comma-separated list of entries.
- Exceptions
-
| LogicError | if the RETURNING clause was already set. |
◆ Rows()
| InsertInto iron_query::InsertInto::Rows |
( |
std::initializer_list< std::initializer_list< Expr > > |
rows | ) |
&& |
Sets multiple rows of values to insert, e.g. Rows({{1, 2}, {3, 4}}) for VALUES (1, 2), (3, 4).
- Exceptions
-
| LogicError | if row values were already set (via this or Values), or if any row's arity does not match an already-set Columns list. |
- Note
- Only each row's count is checked, not that every row has the same arity as every other row, nor value types against columns.
-
Not an overload of Values — for a single-column table,
{{v}} can list-initialize either a lone Expr or a one-element std::initializer_list<Expr>, so overloading would make that call ambiguous.
◆ ToString()
| std::string iron_query::InsertInto::ToString |
( |
| ) |
const |
- Exceptions
-
| LogicError | if no columns or no rows were set, or if any row's arity does not match the columns' count. |
◆ Values()
| InsertInto iron_query::InsertInto::Values |
( |
std::initializer_list< Expr > |
vals | ) |
&& |
Sets a single row of values to insert, matching Columns by position.
- Exceptions
-
| LogicError | if row values were already set (via this or Rows), or if the count does not match an already-set Columns list. |
- Note
- Only the count is checked; each value's SQL type is not checked against the corresponding column's declared type.
The documentation for this class was generated from the following file: