relx 0.1.0
A Modern C++23 Type-Safe SQL Query Builder
Loading...
Searching...
No Matches
helpers.hpp
Go to the documentation of this file.
1#pragma once
2
4#include "condition.hpp"
5#include "core.hpp"
6#include "function.hpp"
7#include "schema_adapter.hpp"
8#include "select.hpp"
9#include "value.hpp"
10
11#include <string>
12#include <type_traits>
13#include <utility>
14
15namespace relx::query {
16
23template <typename Columns, TableType Table>
24auto from(const SelectQuery<Columns>& query, const Table& table) {
25 auto adapter = to_table(table);
26 return query.template from<decltype(adapter)>(adapter);
27}
28
46template <typename Columns, typename Tables, typename Joins, typename Where, typename GroupBys,
47 typename OrderBys, typename HavingCond, typename LimitVal, typename OffsetVal,
48 TableType Table, ConditionExpr Condition>
49auto join(const SelectQuery<Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal,
50 OffsetVal>& query,
51 const Table& table, Condition cond, JoinType type = JoinType::Inner) {
52 auto adapter = to_table(table);
53 return query.template join<decltype(adapter), Condition>(adapter, std::move(cond), type);
54}
55
56} // namespace relx::query
Base SELECT query builder.
Definition select.hpp:63
JoinType
Types of JOIN operations.
Definition core.hpp:68
auto join(const SelectQuery< Columns, Tables, Joins, Where, GroupBys, OrderBys, HavingCond, LimitVal, OffsetVal > &query, const Table &table, Condition cond, JoinType type=JoinType::Inner)
JOIN extension for schema tables with automatic adapter creation.
Definition helpers.hpp:49
auto from(const SelectQuery< Columns > &query, const Table &table)
FROM extension for schema tables with automatic adapter creation.
Definition helpers.hpp:24
auto to_table(const T &table)
Helper to wrap a schema table in a table adapter.