Lightweight 0.20260921.0
Loading...
Searching...
No Matches
Lightweight::SqlJoinConditionBuilder Class Reference

Query builder for building JOIN conditions. More...

#include <Core.hpp>

Public Member Functions

 SqlJoinConditionBuilder (std::string_view referenceTable, SqlSearchCondition *searchCondition, SqlQueryFormatter const *formatter) noexcept
 
SqlJoinConditionBuilder & On (std::string_view joinColumnName, SqlQualifiedTableColumnName onOtherColumn)
 Adds an AND join condition.
 
SqlJoinConditionBuilder & OrOn (std::string_view joinColumnName, SqlQualifiedTableColumnName onOtherColumn)
 Adds an OR join condition.
 
SqlJoinConditionBuilder & Operator (std::string_view joinColumnName, SqlQualifiedTableColumnName onOtherColumn, std::string_view op)
 Adds a join condition with a custom operator.
 
template<typename T >
SqlJoinConditionBuilder & OnValue (std::string_view joinColumnName, T const &value)
 
template<typename T >
SqlJoinConditionBuilder & OnValue (std::string_view joinColumnName, std::string_view binaryOp, T const &value)
 Adds an AND join condition testing the joined column against value with binaryOp.
 
template<typename T >
SqlJoinConditionBuilder & OrOnValue (std::string_view joinColumnName, T const &value)
 Adds an OR join condition testing the joined column against value for equality.
 
template<typename T >
SqlJoinConditionBuilder & OrOnValue (std::string_view joinColumnName, std::string_view binaryOp, T const &value)
 Adds an OR join condition testing the joined column against value with binaryOp.
 
SqlJoinConditionBuilder & OnNull (std::string_view joinColumnName)
 Adds an AND join condition testing the joined column for NULL.
 
SqlJoinConditionBuilder & OnNotNull (std::string_view joinColumnName)
 Adds an AND join condition testing the joined column for NOT NULL.
 
SqlJoinConditionBuilder & OrOnNull (std::string_view joinColumnName)
 Adds an OR join condition testing the joined column for NULL.
 
SqlJoinConditionBuilder & OrOnNotNull (std::string_view joinColumnName)
 Adds an OR join condition testing the joined column for NOT NULL.
 
template<typename Callable >
requires std::invocable<Callable, SqlJoinConditionBuilder&>
SqlJoinConditionBuilder & OnGroup (Callable const &build)
 
template<typename Callable >
requires std::invocable<Callable, SqlJoinConditionBuilder&>
SqlJoinConditionBuilder & OrOnGroup (Callable const &build)
 Adds an OR group of join conditions, in parentheses.
 

Detailed Description

Query builder for building JOIN conditions.

An ON clause can say what a WHERE clause can: compare the joined table's column against another table's column or against a value, test it for null, and group terms in parentheses. The distinction matters for an outer join, where moving a term from the ON clause to the WHERE clause turns the join into an inner one.

Definition at line 170 of file Core.hpp.

Constructor & Destructor Documentation

◆ SqlJoinConditionBuilder()

Lightweight::SqlJoinConditionBuilder::SqlJoinConditionBuilder ( std::string_view  referenceTable,
SqlSearchCondition *  searchCondition,
SqlQueryFormatter const *  formatter 
)
inlineexplicitnoexcept

Constructs a new SqlJoinConditionBuilder.

Parameters
referenceTableThe table being joined; the left operand of every condition.
searchConditionThe query's search condition, whose tableJoins is written into and whose bindings vector, when present, receives the compared values.
formatterSupplies the dialect's spelling of a boolean literal.

Definition at line 179 of file Core.hpp.

Member Function Documentation

◆ On()

SqlJoinConditionBuilder & Lightweight::SqlJoinConditionBuilder::On ( std::string_view  joinColumnName,
SqlQualifiedTableColumnName  onOtherColumn 
)
inline

Adds an AND join condition.

Definition at line 189 of file Core.hpp.

References Operator().

◆ OrOn()

SqlJoinConditionBuilder & Lightweight::SqlJoinConditionBuilder::OrOn ( std::string_view  joinColumnName,
SqlQualifiedTableColumnName  onOtherColumn 
)
inline

Adds an OR join condition.

Definition at line 195 of file Core.hpp.

References Operator().

◆ Operator()

SqlJoinConditionBuilder & Lightweight::SqlJoinConditionBuilder::Operator ( std::string_view  joinColumnName,
SqlQualifiedTableColumnName  onOtherColumn,
std::string_view  op 
)
inline

Adds a join condition with a custom operator.

Definition at line 201 of file Core.hpp.

Referenced by On(), and OrOn().

◆ OnValue() [1/2]

template<typename T >
SqlJoinConditionBuilder & Lightweight::SqlJoinConditionBuilder::OnValue ( std::string_view  joinColumnName,
T const &  value 
)
inline

Adds an AND join condition testing the joined column against value for equality.

The value is bound when the query was given a bindings vector, and written into the statement text otherwise – the same rule the WHERE clause follows. A query whose ON clause binds must be run through SqlStatement::ExecuteWithVariants, and the vector and anything a stored string_view points at have to outlive the execution.

Definition at line 219 of file Core.hpp.

◆ OnValue() [2/2]

template<typename T >
SqlJoinConditionBuilder & Lightweight::SqlJoinConditionBuilder::OnValue ( std::string_view  joinColumnName,
std::string_view  binaryOp,
T const &  value 
)
inline

Adds an AND join condition testing the joined column against value with binaryOp.

Definition at line 226 of file Core.hpp.

◆ OrOnValue() [1/2]

template<typename T >
SqlJoinConditionBuilder & Lightweight::SqlJoinConditionBuilder::OrOnValue ( std::string_view  joinColumnName,
T const &  value 
)
inline

Adds an OR join condition testing the joined column against value for equality.

Definition at line 233 of file Core.hpp.

◆ OrOnValue() [2/2]

template<typename T >
SqlJoinConditionBuilder & Lightweight::SqlJoinConditionBuilder::OrOnValue ( std::string_view  joinColumnName,
std::string_view  binaryOp,
T const &  value 
)
inline

Adds an OR join condition testing the joined column against value with binaryOp.

Definition at line 240 of file Core.hpp.

◆ OnNull()

SqlJoinConditionBuilder & Lightweight::SqlJoinConditionBuilder::OnNull ( std::string_view  joinColumnName)
inline

Adds an AND join condition testing the joined column for NULL.

Definition at line 246 of file Core.hpp.

◆ OnNotNull()

SqlJoinConditionBuilder & Lightweight::SqlJoinConditionBuilder::OnNotNull ( std::string_view  joinColumnName)
inline

Adds an AND join condition testing the joined column for NOT NULL.

Definition at line 252 of file Core.hpp.

◆ OrOnNull()

SqlJoinConditionBuilder & Lightweight::SqlJoinConditionBuilder::OrOnNull ( std::string_view  joinColumnName)
inline

Adds an OR join condition testing the joined column for NULL.

Definition at line 258 of file Core.hpp.

◆ OrOnNotNull()

SqlJoinConditionBuilder & Lightweight::SqlJoinConditionBuilder::OrOnNotNull ( std::string_view  joinColumnName)
inline

Adds an OR join condition testing the joined column for NOT NULL.

Definition at line 264 of file Core.hpp.

◆ OnGroup()

template<typename Callable >
requires std::invocable<Callable, SqlJoinConditionBuilder&>
SqlJoinConditionBuilder & Lightweight::SqlJoinConditionBuilder::OnGroup ( Callable const &  build)
inline

Adds an AND group of join conditions, in parentheses.

The parentheses are what keep a AND (b OR c) from becoming a AND b OR c, which selects strictly more.

Definition at line 275 of file Core.hpp.

◆ OrOnGroup()

template<typename Callable >
requires std::invocable<Callable, SqlJoinConditionBuilder&>
SqlJoinConditionBuilder & Lightweight::SqlJoinConditionBuilder::OrOnGroup ( Callable const &  build)
inline

Adds an OR group of join conditions, in parentheses.

Definition at line 283 of file Core.hpp.


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