|
Lightweight 0.20260617.0
|
Compile-time gate for SELECT query construction. More...
#include <Select.hpp>
Public Member Functions | |
| SqlSelectQueryStarter (SqlQueryFormatter const &formatter, std::string table, std::string tableAlias) noexcept | |
| Constructs a SELECT query starter. | |
| template<typename Self > | |
| auto | All (this Self const &self) -> ComposedQuery |
Empty-projection guard for the All finalizer. | |
| template<typename Self > | |
| auto | First (this Self const &self, size_t count=1) -> ComposedQuery |
Empty-projection guard for the First finalizer — see All. | |
| template<typename Self > | |
| auto | Range (this Self const &self, std::size_t offset, std::size_t limit) -> ComposedQuery |
Empty-projection guard for the Range finalizer — see All. | |
| template<typename Self > | |
| LIGHTWEIGHT_FORCE_INLINE auto && | Distinct (this Self &&self) noexcept |
State-preserving override: returns Self&&, so the starter identity survives the call and the All / First / Range guards above keep their gate against Select().Distinct().All(). | |
| template<typename Self > | |
| LIGHTWEIGHT_FORCE_INLINE auto && | Varying (this Self &&self) noexcept |
| State-preserving override; see Distinct. | |
Public Member Functions inherited from Lightweight::SqlSelectQueryBuilder | |
| SqlSelectQueryBuilder (SqlQueryFormatter const &formatter, std::string table, std::string tableAlias) noexcept | |
| Constructs a SELECT query builder. | |
| constexpr LIGHTWEIGHT_FORCE_INLINE SqlSelectQueryBuilder & | Varying () noexcept |
| Sets the builder mode to Varying, allowing varying final query types. | |
| template<typename... MoreFields> | |
| SqlSelectQueryBuilder & | Fields (std::string_view const &firstField, MoreFields &&... moreFields) |
| Adds a sequence of columns to the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder & | Field (std::string_view const &fieldName) |
| Adds a single column to the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder const & | Field (std::string_view const &fieldName) const |
| Adds a single column to the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder & | Field (SqlQualifiedTableColumnName const &fieldName) |
| Adds a single column to the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder const & | Field (SqlQualifiedTableColumnName const &fieldName) const |
| Adds a single column to the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder & | Field (SqlFieldExpression const &fieldExpression) |
| Adds an aggregate function call to the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder const & | Field (SqlFieldExpression const &fieldExpression) const |
| Adds an aggregate function call to the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder & | As (std::string_view alias) |
| Aliases the last added field (a column or an aggregate call) in the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder const & | As (std::string_view alias) const |
| Aliases the last added field (a column or an aggregate call) in the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder & | Fields (std::vector< std::string_view > const &fieldNames) |
| Adds a sequence of columns to the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder const & | Fields (std::vector< std::string_view > const &fieldNames) const |
| Adds a sequence of columns to the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder & | Fields (std::vector< std::string_view > const &fieldNames, std::string_view tableName) |
| Adds a sequence of columns from the given table to the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder const & | Fields (std::vector< std::string_view > const &fieldNames, std::string_view tableName) const |
| Adds a sequence of columns from the given table to the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder & | Fields (std::initializer_list< std::string_view > const &fieldNames, std::string_view tableName) |
| Adds a sequence of columns from the given table to the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder const & | Fields (std::initializer_list< std::string_view > const &fieldNames, std::string_view tableName) const |
| Adds a sequence of columns from the given table to the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder & | Fields (std::span< SqlQualifiedTableColumnName const > fieldNames) |
| Adds a sequence of qualified table column names to the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder const & | Fields (std::span< SqlQualifiedTableColumnName const > fieldNames) const |
| Adds a sequence of qualified table column names to the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder & | Fields (std::initializer_list< SqlQualifiedTableColumnName const > fieldNames) |
| Adds a sequence of qualified table column names to the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder const & | Fields (std::initializer_list< SqlQualifiedTableColumnName const > fieldNames) const |
| Adds a sequence of qualified table column names to the SELECT clause. | |
| template<typename FirstRecord , typename... MoreRecords> | |
| SqlSelectQueryBuilder & | Fields () |
| Adds a sequence of columns from the given tables to the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder & | FieldAs (std::string_view const &fieldName, std::string_view const &alias) |
| Adds a single column with an alias to the SELECT clause. | |
| LIGHTWEIGHT_API SqlSelectQueryBuilder & | FieldAs (SqlQualifiedTableColumnName const &fieldName, std::string_view const &alias) |
| Adds a single column with an alias to the SELECT clause. | |
| template<typename Callable > | |
| SqlSelectQueryBuilder & | Build (Callable const &callable) |
| Builds the query using a callable. | |
| LIGHTWEIGHT_API ComposedQuery | Count () |
| Finalizes building the query as SELECT COUNT(*) ... query. | |
| LIGHTWEIGHT_API ComposedQuery | Count () const |
| Finalizes building the query as SELECT COUNT(*) ... query. | |
| LIGHTWEIGHT_API ComposedQuery | All () |
| Finalizes building the query as SELECT field names FROM ... query. | |
| LIGHTWEIGHT_API ComposedQuery | All () const |
| Finalizes building the query as SELECT field names FROM ... query. | |
| LIGHTWEIGHT_API ComposedQuery | First (size_t count=1) |
| Finalizes building the query as SELECT TOP n field names FROM ... query. | |
| LIGHTWEIGHT_API ComposedQuery | First (size_t count=1) const |
| Finalizes building the query as SELECT TOP n field names FROM ... query. | |
| LIGHTWEIGHT_API ComposedQuery | Range (std::size_t offset, std::size_t limit) |
| Finalizes building the query as SELECT field names FROM ... query with a range. | |
| LIGHTWEIGHT_API ComposedQuery | Range (std::size_t offset, std::size_t limit) const |
| Finalizes building the query as SELECT field names FROM ... query with a range. | |
| LIGHTWEIGHT_FORCE_INLINE SqlSearchCondition & | SearchCondition () noexcept |
| Returns the search condition for the query. | |
| LIGHTWEIGHT_FORCE_INLINE SqlQueryFormatter const & | Formatter () const noexcept |
| Returns the SQL query formatter. | |
| template<typename Callable > | |
| LIGHTWEIGHT_FORCE_INLINE SqlSelectQueryBuilder & | Build (Callable const &callable) |
| Builds the query using a callable. | |
| template<typename FirstRecord , typename... MoreRecords> | |
| LIGHTWEIGHT_FORCE_INLINE SqlSelectQueryBuilder & | Fields () |
| Adds fields from one or more record types to the SELECT clause. | |
Additional Inherited Members | |
Public Types inherited from Lightweight::SqlSelectQueryBuilder | |
| using | SelectType = detail::SelectType |
| The select query type alias. | |
Compile-time gate for SELECT query construction.
Returned by SqlQueryBuilder::Select(). The starter inherits publicly from SqlSelectQueryBuilder (so every projection / WHERE / JOIN method resolves directly through inheritance), but defines its own All, First, and Range as deducing-this member templates whose bodies are ill-formed via static_assert. Those locals shadow the corresponding base methods at name lookup, so:
Select().All(), Select().First(), Select().Range(...) — and the two-step variant auto q = Select(); q.All(); — fail at compile time with a diagnostic asking the user to add a projection first. Without a projection these would emit malformed SELECT FROM "T" SQL.Select().Field(...).All() compiles: Field(...) is inherited and returns SqlSelectQueryBuilder&, so the subsequent All() resolves against the base type (no shadowing) and reaches the real finalizer.Count is intentionally not overridden — SELECT COUNT(*) FROM ... is well-formed without an explicit column list, so the inherited Count remains directly callable.Distinct and Varying are overridden via deducing this so they return Self&& and the starter identity survives them. That keeps the gate intact for Select().Distinct().All() while still allowing Select().Distinct().Fields(...).All().Methods that conceptually follow the column list (Where, OrderBy, GroupBy, InnerJoin, LeftOuterJoin, etc.) are reachable on the starter through public inheritance and return SqlSelectQueryBuilder&, which technically lets Select().WhereNotNull("x").All() compile (a known gate leak the type primarily defends against the empty-Select().All() typo, which is far more common).
For the imperative loop pattern, capture the first projection as a builder reference and continue from there:
Definition at line 373 of file Select.hpp.
|
inlinenoexcept |
Constructs a SELECT query starter.
Intentionally not explicit so the factory in SqlQueryBuilder::Select can return via braced init.
Definition at line 380 of file Select.hpp.
|
inline |
Empty-projection guard for the All finalizer.
Instantiating this template emits a static_assert telling the caller to add a projection first. Calling All() on a SqlSelectQueryBuilder& returned by Field(...) / Fields(...) bypasses the shadow and reaches the real SqlSelectQueryBuilder::All().
Definition at line 392 of file Select.hpp.
|
inline |
Empty-projection guard for the First finalizer — see All.
Definition at line 404 of file Select.hpp.
|
inline |
Empty-projection guard for the Range finalizer — see All.
Definition at line 416 of file Select.hpp.
|
inlinenoexcept |
State-preserving override: returns Self&&, so the starter identity survives the call and the All / First / Range guards above keep their gate against Select().Distinct().All().
Definition at line 431 of file Select.hpp.
|
inlinenoexcept |
State-preserving override; see Distinct.
Definition at line 439 of file Select.hpp.