|
| | SelectQuery (Columns columns, Tables tables={}, Joins joins={}, Where where=std::nullopt, GroupBys group_bys={}, OrderBys order_bys={}, HavingCond having=std::nullopt, LimitVal limit=std::nullopt, OffsetVal offset=std::nullopt) |
| | Constructor for the SELECT query builder.
|
| |
| std::string | to_sql () const |
| | Generate the SQL for this SELECT query.
|
| |
| std::vector< std::string > | bind_params () const |
| | Get the bind parameters for this SELECT query.
|
| |
| template<TableType T> |
| auto | from (const T &table) const |
| | Add a FROM clause to the query.
|
| |
| template<TableType... Args> |
| auto | from (const Args &... tables) const |
| | Add a FROM clause with multiple tables.
|
| |
| template<TableType Table, ConditionExpr Condition> |
| auto | join (const Table &table, const Condition &cond, JoinType type=JoinType::Inner) const |
| | Add a JOIN clause to the query.
|
| |
| template<TableType Table, ConditionExpr Condition> |
| auto | left_join (const Table &table, const Condition &cond) const |
| | Add a LEFT JOIN clause to the query.
|
| |
| template<TableType Table, ConditionExpr Condition> |
| auto | right_join (const Table &table, const Condition &cond) const |
| | Add a RIGHT JOIN clause to the query.
|
| |
| template<TableType Table, ConditionExpr Condition> |
| auto | full_join (const Table &table, const Condition &cond) const |
| | Add a FULL JOIN clause to the query.
|
| |
| template<TableType Table> |
| auto | cross_join (const Table &table) const |
| | Add a CROSS JOIN clause to the query.
|
| |
| template<ConditionExpr Condition> |
| auto | where (const Condition &cond) const |
| | Add a WHERE clause to the query.
|
| |
| template<typename... Args> |
| auto | group_by (const Args &... args) const |
| | Add a GROUP BY clause to the query.
|
| |
| template<ConditionExpr Condition> |
| auto | having (const Condition &cond) const |
| | Add a HAVING clause to the query.
|
| |
| template<SqlExpr... Args> |
| auto | order_by (const Args &... args) const |
| | Add an ORDER BY clause to the query.
|
| |
template<typename T >
requires ColumnType<T> |
| auto | order_by (const T &column) const |
| | Add an ORDER BY clause to the query.
|
| |
| auto | limit (int limit) const |
| | Add a LIMIT clause to the query.
|
| |
| auto | offset (int offset) const |
| | Add an OFFSET clause to the query.
|
| |
template<typename Columns, typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
class relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >
Base SELECT query builder.
- Template Parameters
-
| Columns | Tuple of column expressions |
| Tables | Tuple of table references |
| Joins | Tuple of join specifications |
| Where | Optional where condition |
| GroupBys | Tuple of group by expressions |
| OrderBys | Tuple of order by expressions |
| HavingCond | Optional having condition |
| LimitVal | Optional limit value |
| OffsetVal | Optional offset value |
| IsDistinct | Whether to use DISTINCT in the query |
Definition at line 63 of file select.hpp.
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
| using relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::columns_type = Columns |
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
| using relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::group_bys_type = GroupBys |
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
| using relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::having_type = HavingCond |
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
| using relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::joins_type = Joins |
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
| using relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::limit_type = LimitVal |
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
| using relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::offset_type = OffsetVal |
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
| using relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::order_bys_type = OrderBys |
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
| using relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::tables_type = Tables |
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
| using relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::where_type = Where |
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
| relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::SelectQuery |
( |
Columns |
columns, |
|
|
Tables |
tables = {}, |
|
|
Joins |
joins = {}, |
|
|
Where |
where = std::nullopt, |
|
|
GroupBys |
group_bys = {}, |
|
|
OrderBys |
order_bys = {}, |
|
|
HavingCond |
having = std::nullopt, |
|
|
LimitVal |
limit = std::nullopt, |
|
|
OffsetVal |
offset = std::nullopt |
|
) |
| |
|
inlineexplicit |
Constructor for the SELECT query builder.
- Parameters
-
| columns | The columns to select |
| tables | The tables to select from |
| joins | The join specifications |
| where | The WHERE condition |
| group_bys | The GROUP BY expressions |
| order_bys | The ORDER BY expressions |
| having | The HAVING condition |
| limit | The LIMIT value |
| offset | The OFFSET value |
Definition at line 86 of file select.hpp.
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
| std::vector< std::string > relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::bind_params |
( |
| ) |
const |
|
inline |
Get the bind parameters for this SELECT query.
- Returns
- Vector of bind parameters
Definition at line 199 of file select.hpp.
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
template<TableType Table>
| auto relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::cross_join |
( |
const Table & |
table | ) |
const |
|
inline |
Add a CROSS JOIN clause to the query.
- Template Parameters
-
| Table | The table type to join |
- Parameters
-
- Returns
- New SelectQuery with the CROSS JOIN clause added
Definition at line 365 of file select.hpp.
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
template<TableType... Args>
| auto relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::from |
( |
const Args &... |
tables | ) |
const |
|
inline |
Add a FROM clause with multiple tables.
- Template Parameters
-
- Parameters
-
| tables | The tables to select from |
- Returns
- New SelectQuery with the FROM clause added
Definition at line 299 of file select.hpp.
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
template<TableType T>
| auto relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::from |
( |
const T & |
table | ) |
const |
|
inline |
Add a FROM clause to the query.
- Template Parameters
-
- Parameters
-
| table | The table to select from |
- Returns
- New SelectQuery with the FROM clause added
Definition at line 286 of file select.hpp.
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
template<TableType Table, ConditionExpr Condition>
| auto relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::full_join |
( |
const Table & |
table, |
|
|
const Condition & |
cond |
|
) |
| const |
|
inline |
Add a FULL JOIN clause to the query.
- Template Parameters
-
| Table | The table type to join |
| Condition | The join condition type |
- Parameters
-
| table | The table to join |
| cond | The join condition |
- Returns
- New SelectQuery with the FULL JOIN clause added
Definition at line 356 of file select.hpp.
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
template<typename... Args>
| auto relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::group_by |
( |
const Args &... |
args | ) |
const |
|
inline |
Add a GROUP BY clause to the query.
- Template Parameters
-
| Args | The group by expression types |
- Parameters
-
| args | The GROUP BY expressions |
- Returns
- New SelectQuery with the GROUP BY clause added
Definition at line 393 of file select.hpp.
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
template<ConditionExpr Condition>
| auto relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::having |
( |
const Condition & |
cond | ) |
const |
|
inline |
Add a HAVING clause to the query.
- Template Parameters
-
| Condition | The condition type |
- Parameters
-
- Returns
- New SelectQuery with the HAVING clause added
Definition at line 417 of file select.hpp.
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
template<TableType Table, ConditionExpr Condition>
| auto relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::join |
( |
const Table & |
table, |
|
|
const Condition & |
cond, |
|
|
JoinType |
type = JoinType::Inner |
|
) |
| const |
|
inline |
Add a JOIN clause to the query.
- Template Parameters
-
| Table | The table type to join |
| Condition | The join condition type |
- Parameters
-
| table | The table to join |
| cond | The join condition |
| type | The join type (default: INNER) |
- Returns
- New SelectQuery with the JOIN clause added
Definition at line 315 of file select.hpp.
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
template<TableType Table, ConditionExpr Condition>
| auto relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::left_join |
( |
const Table & |
table, |
|
|
const Condition & |
cond |
|
) |
| const |
|
inline |
Add a LEFT JOIN clause to the query.
- Template Parameters
-
| Table | The table type to join |
| Condition | The join condition type |
- Parameters
-
| table | The table to join |
| cond | The join condition |
- Returns
- New SelectQuery with the LEFT JOIN clause added
Definition at line 334 of file select.hpp.
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
| auto relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::limit |
( |
int |
limit | ) |
const |
|
inline |
Add a LIMIT clause to the query.
- Parameters
-
- Returns
- New SelectQuery with the LIMIT clause added
Definition at line 460 of file select.hpp.
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
| auto relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::offset |
( |
int |
offset | ) |
const |
|
inline |
Add an OFFSET clause to the query.
- Parameters
-
- Returns
- New SelectQuery with the OFFSET clause added
Definition at line 472 of file select.hpp.
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
template<SqlExpr... Args>
| auto relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::order_by |
( |
const Args &... |
args | ) |
const |
|
inline |
Add an ORDER BY clause to the query.
- Template Parameters
-
| Args | The order by expression types |
- Parameters
-
| args | The ORDER BY expressions |
- Returns
- New SelectQuery with the ORDER BY clause added
Definition at line 429 of file select.hpp.
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
template<typename T >
requires ColumnType<T>
| auto relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::order_by |
( |
const T & |
column | ) |
const |
|
inline |
Add an ORDER BY clause to the query.
- Template Parameters
-
- Parameters
-
| column | The column to order by |
- Returns
- New SelectQuery with the ORDER BY clause added
Definition at line 444 of file select.hpp.
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
template<TableType Table, ConditionExpr Condition>
| auto relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::right_join |
( |
const Table & |
table, |
|
|
const Condition & |
cond |
|
) |
| const |
|
inline |
Add a RIGHT JOIN clause to the query.
- Template Parameters
-
| Table | The table type to join |
| Condition | The join condition type |
- Parameters
-
| table | The table to join |
| cond | The join condition |
- Returns
- New SelectQuery with the RIGHT JOIN clause added
Definition at line 345 of file select.hpp.
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
| std::string relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::to_sql |
( |
| ) |
const |
|
inline |
Generate the SQL for this SELECT query.
- Returns
- The SQL string
Definition at line 97 of file select.hpp.
template<typename Columns , typename Tables = std::tuple<>, typename Joins = std::tuple<>, typename Where = std::nullopt_t, typename GroupBys = std::tuple<>, typename OrderBys = std::tuple<>, typename HavingCond = std::nullopt_t, typename LimitVal = std::nullopt_t, typename OffsetVal = std::nullopt_t, bool IsDistinct = false>
template<ConditionExpr Condition>
| auto relx::query::SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal, IsDistinct >::where |
( |
const Condition & |
cond | ) |
const |
|
inline |
Add a WHERE clause to the query.
- Template Parameters
-
| Condition | The condition type |
- Parameters
-
- Returns
- New SelectQuery with the WHERE clause added
Definition at line 381 of file select.hpp.