Lightweight 0.20260303.0
Loading...
Searching...
No Matches
Lightweight::SqlSelectQueryBuilder Class Referencefinal

Query builder for building SELECT ... queries. More...

#include <Select.hpp>

Inherits Lightweight::SqlBasicSelectQueryBuilder< Derived >.

Public Types

using SelectType = detail::SelectType
 The select query type alias.
 

Public Member Functions

 SqlSelectQueryBuilder (SqlQueryFormatter const &formatter, std::string table, std::string tableAlias) noexcept
 Constructs a SELECT query builder.
 
constexpr LIGHTWEIGHT_FORCE_INLINE SqlSelectQueryBuilderVarying () noexcept
 Sets the builder mode to Varying, allowing varying final query types.
 
template<typename... MoreFields>
SqlSelectQueryBuilderFields (std::string_view const &firstField, MoreFields &&... moreFields)
 Adds a sequence of columns to the SELECT clause.
 
LIGHTWEIGHT_API SqlSelectQueryBuilderField (std::string_view const &fieldName)
 Adds a single column to the SELECT clause.
 
LIGHTWEIGHT_API SqlSelectQueryBuilderField (SqlQualifiedTableColumnName const &fieldName)
 Adds a single column to the SELECT clause.
 
LIGHTWEIGHT_API SqlSelectQueryBuilderField (SqlFieldExpression const &fieldExpression)
 Adds an aggregate function call to the SELECT clause.
 
LIGHTWEIGHT_API SqlSelectQueryBuilderAs (std::string_view alias)
 Aliases the last added field (a column or an aggregate call) in the SELECT clause.
 
LIGHTWEIGHT_API SqlSelectQueryBuilderFields (std::vector< std::string_view > const &fieldNames)
 Adds a sequence of columns to the SELECT clause.
 
LIGHTWEIGHT_API SqlSelectQueryBuilderFields (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 SqlSelectQueryBuilderFields (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 SqlSelectQueryBuilderFields (std::span< SqlQualifiedTableColumnName const > fieldNames)
 Adds a sequence of qualified table column names to the SELECT clause.
 
LIGHTWEIGHT_API SqlSelectQueryBuilderFields (std::initializer_list< SqlQualifiedTableColumnName const > fieldNames)
 Adds a sequence of qualified table column names to the SELECT clause.
 
template<typename FirstRecord , typename... MoreRecords>
SqlSelectQueryBuilderFields ()
 Adds a sequence of columns from the given tables to the SELECT clause.
 
LIGHTWEIGHT_API SqlSelectQueryBuilderFieldAs (std::string_view const &fieldName, std::string_view const &alias)
 Adds a single column with an alias to the SELECT clause.
 
LIGHTWEIGHT_API SqlSelectQueryBuilderFieldAs (SqlQualifiedTableColumnName const &fieldName, std::string_view const &alias)
 Adds a single column with an alias to the SELECT clause.
 
template<typename Callable >
SqlSelectQueryBuilderBuild (Callable const &callable)
 Builds the query using a callable.
 
LIGHTWEIGHT_API ComposedQuery Count ()
 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 First (size_t count=1)
 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_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 SqlSelectQueryBuilderBuild (Callable const &callable)
 Builds the query using a callable.
 
template<typename FirstRecord , typename... MoreRecords>
LIGHTWEIGHT_FORCE_INLINE SqlSelectQueryBuilderFields ()
 Adds fields from one or more record types to the SELECT clause.
 

Detailed Description

Query builder for building SELECT ... queries.

See also
SqlQueryBuilder

Definition at line 85 of file Select.hpp.

Member Typedef Documentation

◆ SelectType

using Lightweight::SqlSelectQueryBuilder::SelectType = detail::SelectType

The select query type alias.

Definition at line 89 of file Select.hpp.

Constructor & Destructor Documentation

◆ SqlSelectQueryBuilder()

Lightweight::SqlSelectQueryBuilder::SqlSelectQueryBuilder ( SqlQueryFormatter const &  formatter,
std::string  table,
std::string  tableAlias 
)
inlineexplicitnoexcept

Constructs a SELECT query builder.

Definition at line 92 of file Select.hpp.

Member Function Documentation

◆ Varying()

constexpr LIGHTWEIGHT_FORCE_INLINE SqlSelectQueryBuilder & Lightweight::SqlSelectQueryBuilder::Varying ( )
inlineconstexprnoexcept

Sets the builder mode to Varying, allowing varying final query types.

Definition at line 103 of file Select.hpp.

◆ Fields() [1/2]

template<typename... MoreFields>
SqlSelectQueryBuilder & Lightweight::SqlSelectQueryBuilder::Fields ( std::string_view const &  firstField,
MoreFields &&...  moreFields 
)

Adds a sequence of columns to the SELECT clause.

Definition at line 194 of file Select.hpp.

◆ SearchCondition()

LIGHTWEIGHT_FORCE_INLINE SqlSearchCondition & Lightweight::SqlSelectQueryBuilder::SearchCondition ( )
inlinenoexcept

Returns the search condition for the query.

Definition at line 173 of file Select.hpp.

◆ Formatter()

LIGHTWEIGHT_FORCE_INLINE SqlQueryFormatter const & Lightweight::SqlSelectQueryBuilder::Formatter ( ) const
inlinenoexcept

Returns the SQL query formatter.

Definition at line 181 of file Select.hpp.

◆ Build()

template<typename Callable >
LIGHTWEIGHT_FORCE_INLINE SqlSelectQueryBuilder & Lightweight::SqlSelectQueryBuilder::Build ( Callable const &  callable)
inline

Builds the query using a callable.

Definition at line 214 of file Select.hpp.

◆ Fields() [2/2]

template<typename FirstRecord , typename... MoreRecords>
LIGHTWEIGHT_FORCE_INLINE SqlSelectQueryBuilder & Lightweight::SqlSelectQueryBuilder::Fields ( )
inline

Adds fields from one or more record types to the SELECT clause.

Definition at line 222 of file Select.hpp.

References Lightweight::SqlQualifiedTableColumnName::tableName.


The documentation for this class was generated from the following file: