|
IronQuery
A SQL-first query builder for C++
|
Transitional representation for SELECT query. More...
#include <select_expr.hpp>


Public Member Functions | |
| SelectExpr (const VirtualTable &tbl) | |
Starts a SELECT ... FROM tbl query. tbl may be a table, a join, or anything VirtualTable::As has aliased. | |
| SelectExpr | Distinct () && |
Adds DISTINCT to the SELECT list, eliminating duplicate rows. | |
| SelectExpr | DistinctOn (Expr exp) && |
| Sets DISTINCT ON to a single expression. Mutually exclusive with Distinct. | |
| SelectExpr | DistinctOn (std::initializer_list< Expr > exps) && |
| Sets DISTINCT ON to a comma-separated list of expressions. Mutually exclusive with Distinct. | |
| SelectExpr | Select (SelectItem item) && |
| Sets the SELECT list to a single entry. | |
| SelectExpr | Select (std::initializer_list< SelectItem > items) && |
| Sets the SELECT list to a comma-separated list of entries. | |
| SelectExpr | Where (Condition exp) && |
| Sets the WHERE clause. | |
| SelectExpr | OrderBy (OrderByTerm term) && |
| Sets the ORDER BY clause to a single term. | |
| SelectExpr | OrderBy (std::initializer_list< OrderByTerm > terms) && |
| Sets the ORDER BY clause to a comma-separated list of terms. | |
| SelectExpr | GroupBy (Expr exp) && |
| Sets the GROUP BY clause to a single expression. | |
| SelectExpr | GroupBy (std::initializer_list< Expr > exps) && |
| Sets the GROUP BY clause to a comma-separated list of expressions. | |
| SelectExpr | Having (Condition exp) && |
| Sets the HAVING clause. | |
| SelectExpr | Limit (int limit) && |
| Sets the LIMIT clause. | |
| SelectExpr | Offset (int offset) && |
| Sets the OFFSET clause. | |
| std::string | ToString () const override |
| std::string | ToStringFormatted () const override |
| Renders the query with each clause on its own line, indented, e.g.: | |
Public Member Functions inherited from iron_query::VirtualTable | |
| virtual std::string | ToStringBracketed () const |
| Renders this table value as SQL text, parenthesized so it can be safely embedded as a subquery. Overridden by Table to skip bracketing, since a bare table name never needs it. | |
| virtual std::string | ToStringAsFromItem () const |
Renders this table value as a FROM item. Distinct from ToStringBracketed because PostgreSQL's table_ref grammar accepts a bare join but parenthesizes one only when an alias follows. | |
| Table | As (std::string_view name) const |
Aliases this table value as this AS name, usable as a FROM source. name must be a valid (optionally dotted) SQL identifier. | |
| operator Expr () const && | |
| Converts this table value into a subquery expression, e.g. for use as a scalar subquery. Only available on rvalues. | |
Transitional representation for SELECT query.
| iron_query::SelectExpr::SelectExpr | ( | const VirtualTable & | tbl | ) |
Starts a SELECT ... FROM tbl query. tbl may be a table, a join, or anything VirtualTable::As has aliased.
| LogicError | if tbl is a subquery without an alias. |
| SelectExpr iron_query::SelectExpr::DistinctOn | ( | Expr | exp | ) | && |
Sets DISTINCT ON to a single expression. Mutually exclusive with Distinct.
| LogicError | if DISTINCT ON was already set. |
| SelectExpr iron_query::SelectExpr::DistinctOn | ( | std::initializer_list< Expr > | exps | ) | && |
Sets DISTINCT ON to a comma-separated list of expressions. Mutually exclusive with Distinct.
ORDER BY expressions match these, which PostgreSQL requires. | LogicError | if DISTINCT ON was already set. |
| SelectExpr iron_query::SelectExpr::GroupBy | ( | Expr | exp | ) | && |
Sets the GROUP BY clause to a single expression.
| LogicError | if the GROUP BY clause was already set. |
| SelectExpr iron_query::SelectExpr::GroupBy | ( | std::initializer_list< Expr > | exps | ) | && |
Sets the GROUP BY clause to a comma-separated list of expressions.
| LogicError | if the GROUP BY clause was already set. |
| SelectExpr iron_query::SelectExpr::Having | ( | Condition | exp | ) | && |
Sets the HAVING clause.
exp references only grouped columns or aggregates. | LogicError | if the HAVING clause was already set. |
| SelectExpr iron_query::SelectExpr::Limit | ( | int | limit | ) | && |
Sets the LIMIT clause.
| LogicError | if the LIMIT clause was already set. |
| SelectExpr iron_query::SelectExpr::Offset | ( | int | offset | ) | && |
Sets the OFFSET clause.
| LogicError | if the OFFSET clause was already set. |
| SelectExpr iron_query::SelectExpr::OrderBy | ( | OrderByTerm | term | ) | && |
Sets the ORDER BY clause to a single term.
| LogicError | if the ORDER BY clause was already set. |
| SelectExpr iron_query::SelectExpr::OrderBy | ( | std::initializer_list< OrderByTerm > | terms | ) | && |
Sets the ORDER BY clause to a comma-separated list of terms.
| LogicError | if the ORDER BY clause was already set. |
| SelectExpr iron_query::SelectExpr::Select | ( | SelectItem | item | ) | && |
Sets the SELECT list to a single entry.
| LogicError | if the SELECT list was already set. |
| SelectExpr iron_query::SelectExpr::Select | ( | std::initializer_list< SelectItem > | items | ) | && |
Sets the SELECT list to a comma-separated list of entries.
| LogicError | if the SELECT list was already set. |
|
overridevirtual |
| LogicError | if the SELECT or FROM clause was not set, or if both Distinct and DistinctOn were set. |
Implements iron_query::VirtualTable.
|
overridevirtual |
Renders the query with each clause on its own line, indented, e.g.:
| LogicError | if the SELECT or FROM clause was not set. |
Reimplemented from iron_query::VirtualTable.
| SelectExpr iron_query::SelectExpr::Where | ( | Condition | exp | ) | && |
Sets the WHERE clause.
| LogicError | if the WHERE clause was already set. |