Lightweight 0.20260921.0
Loading...
Searching...
No Matches
Lightweight::SqlDeleteQueryBuilder Class Referencefinal

Query builder for building DELETE FROM ... queries. More...

#include <Delete.hpp>

Inheritance diagram for Lightweight::SqlDeleteQueryBuilder:
Lightweight::SqlWhereClauseBuilder< SqlDeleteQueryBuilder >

Public Member Functions

 SqlDeleteQueryBuilder (SqlQueryFormatter const &formatter, std::string table, std::string tableAlias, std::vector< SqlVariant > *inputBindings=nullptr) noexcept
 
SqlSearchCondition & SearchCondition () noexcept
 Returns the search condition for the query.
 
SqlQueryFormatter const & Formatter () const noexcept
 Returns the SQL query formatter.
 
std::string ToSql () const
 Finalizes building the query as DELETE FROM ... query.
 
- Public Member Functions inherited from Lightweight::SqlWhereClauseBuilder< SqlDeleteQueryBuilder >
SqlDeleteQueryBuilder & And () noexcept
 Indicates, that the next WHERE clause should be AND-ed (default).
 
SqlDeleteQueryBuilder & Or () noexcept
 Indicates, that the next WHERE clause should be OR-ed.
 
SqlDeleteQueryBuilder & Not () noexcept
 Indicates, that the next WHERE clause should be negated.
 
SqlDeleteQueryBuilder & WhereRaw (std::string_view sqlConditionExpression)
 Constructs or extends a raw WHERE clause.
 
auto If (std::optional< T > const &value) noexcept
 Starts a conditional WHERE chain driven by a std::optional<T> value.
 
LIGHTWEIGHT_FORCE_INLINE auto If (std::optional< T > const &value) noexcept
 Starts a conditional WHERE chain gated by a std::optional value.
 
SqlDeleteQueryBuilder & Where (ColumnName const &columnName, std::string_view binaryOp, T const &value)
 Constructs or extends a WHERE clause to test for a binary operation.
 
SqlDeleteQueryBuilder & Where (ColumnName const &columnName, std::string_view binaryOp, SubSelectQuery const &value)
 Constructs or extends a WHERE clause to test for a binary operation for RHS as sub-select query.
 
SqlDeleteQueryBuilder & Where (ColumnName const &columnName, std::string_view binaryOp, char const(&value)[N])
 Constructs or extends a WHERE clause to test for a binary operation for RHS as string literal.
 
SqlDeleteQueryBuilder & Where (ColumnName const &columnName, T const &value)
 Constructs or extends a WHERE clause to test for equality.
 
SqlDeleteQueryBuilder & Where (Callable const &callable)
 Constructs or extends a WHERE/AND clause to test for a group of values.
 
LIGHTWEIGHT_FORCE_INLINE SqlDeleteQueryBuilder & Where (ColumnName const &columnName, T const &value)
 Constructs or extends a WHERE clause to test for equality.
 
LIGHTWEIGHT_FORCE_INLINE SqlDeleteQueryBuilder & Where (Callable const &callable)
 Constructs or extends a WHERE/AND clause to test for a group of values.
 
LIGHTWEIGHT_FORCE_INLINE SqlDeleteQueryBuilder & Where (ColumnName const &columnName, std::string_view binaryOp, char const(&value)[N])
 Constructs or extends a WHERE clause with a string literal value.
 
LIGHTWEIGHT_FORCE_INLINE SqlDeleteQueryBuilder & Where (ColumnName const &columnName, std::string_view binaryOp, T const &value)
 Constructs or extends a WHERE clause to test for a binary operation.
 
LIGHTWEIGHT_FORCE_INLINE SqlDeleteQueryBuilder & Where (ColumnName const &columnName, std::string_view binaryOp, SubSelectQuery const &value)
 Constructs or extends a WHERE clause with a sub-select query.
 
SqlDeleteQueryBuilder & OrWhere (ColumnName const &columnName, std::string_view binaryOp, T const &value)
 Constructs or extends a WHERE/OR clause to test for a binary operation.
 
SqlDeleteQueryBuilder & OrWhere (ColumnName const &columnName, T const &value)
 Constructs or extends an WHERE/OR clause to test for equality.
 
SqlDeleteQueryBuilder & OrWhere (Callable const &callable)
 Constructs or extends an WHERE/OR clause to test for a group of values.
 
LIGHTWEIGHT_FORCE_INLINE SqlDeleteQueryBuilder & OrWhere (ColumnName const &columnName, T const &value)
 Constructs or extends a WHERE/OR clause to test for equality.
 
LIGHTWEIGHT_FORCE_INLINE SqlDeleteQueryBuilder & OrWhere (Callable const &callable)
 Constructs or extends a WHERE/OR clause to test for a group of values.
 
LIGHTWEIGHT_FORCE_INLINE SqlDeleteQueryBuilder & OrWhere (ColumnName const &columnName, std::string_view binaryOp, T const &value)
 Constructs or extends a WHERE/OR clause with a binary operation.
 
SqlDeleteQueryBuilder & WhereIn (ColumnName const &columnName, InputRange const &values)
 Constructs or extends an WHERE/OR clause to test for a value, satisfying std::ranges::input_range.
 
SqlDeleteQueryBuilder & WhereIn (ColumnName const &columnName, std::initializer_list< T > const &values)
 Constructs or extends an WHERE/OR clause to test for a value, satisfying std::initializer_list.
 
SqlDeleteQueryBuilder & WhereIn (ColumnName const &columnName, SubSelectQuery const &subSelectQuery)
 Constructs or extends an WHERE/OR clause to test for a value, satisfying a sub-select query.
 
LIGHTWEIGHT_FORCE_INLINE SqlDeleteQueryBuilder & WhereIn (ColumnName const &columnName, InputRange const &values)
 Constructs or extends a WHERE IN clause with an input range.
 
LIGHTWEIGHT_FORCE_INLINE SqlDeleteQueryBuilder & WhereIn (ColumnName const &columnName, std::initializer_list< T > const &values)
 Constructs or extends a WHERE IN clause with an initializer list.
 
LIGHTWEIGHT_FORCE_INLINE SqlDeleteQueryBuilder & WhereIn (ColumnName const &columnName, SubSelectQuery const &subSelectQuery)
 Constructs or extends a WHERE IN clause with a sub-select query.
 
SqlDeleteQueryBuilder & WhereNull (ColumnName const &columnName)
 Constructs or extends an WHERE/OR clause to test for a value to be NULL.
 
LIGHTWEIGHT_FORCE_INLINE SqlDeleteQueryBuilder & WhereNull (ColumnName const &columnName)
 Constructs or extends a WHERE clause to test for a value being null.
 
SqlDeleteQueryBuilder & WhereNotNull (ColumnName const &columnName)
 Constructs or extends a WHERE clause to test for a value being not null.
 
LIGHTWEIGHT_FORCE_INLINE SqlDeleteQueryBuilder & WhereNotNull (ColumnName const &columnName)
 Constructs or extends a WHERE clause to test for a value being not null.
 
SqlDeleteQueryBuilder & WhereNotEqual (ColumnName const &columnName, T const &value)
 Constructs or extends a WHERE clause to test for a value being equal to another column.
 
LIGHTWEIGHT_FORCE_INLINE SqlDeleteQueryBuilder & WhereNotEqual (ColumnName const &columnName, T const &value)
 Constructs or extends a WHERE clause to test for inequality.
 
SqlDeleteQueryBuilder & WhereTrue (ColumnName const &columnName)
 Constructs or extends a WHERE clause to test for a value being true.
 
LIGHTWEIGHT_FORCE_INLINE SqlDeleteQueryBuilder & WhereTrue (ColumnName const &columnName)
 Constructs or extends a WHERE clause to test for a value being true.
 
SqlDeleteQueryBuilder & WhereFalse (ColumnName const &columnName)
 Constructs or extends a WHERE clause to test for a value being false.
 
LIGHTWEIGHT_FORCE_INLINE SqlDeleteQueryBuilder & WhereFalse (ColumnName const &columnName)
 Constructs or extends a WHERE clause to test for a value being false.
 
SqlDeleteQueryBuilder & InnerJoin (TableName auto joinTable, std::string_view joinColumnName, SqlQualifiedTableColumnName onOtherColumn)
 
SqlDeleteQueryBuilder & InnerJoin (TableName auto joinTable, std::string_view joinColumnName, std::string_view onMainTableColumn)
 Constructs an INNER JOIN clause.
 
SqlDeleteQueryBuilder & InnerJoin (TableName auto joinTable, OnChainCallable const &onClauseBuilder)
 Constructs an INNER JOIN clause with a custom ON clause.
 
SqlDeleteQueryBuilder & InnerJoin ()
 
SqlDeleteQueryBuilder & LeftOuterJoin (TableName auto joinTable, std::string_view joinColumnName, SqlQualifiedTableColumnName onOtherColumn)
 Constructs an LEFT OUTER JOIN clause.
 
SqlDeleteQueryBuilder & LeftOuterJoin (TableName auto joinTable, std::string_view joinColumnName, std::string_view onMainTableColumn)
 Constructs an LEFT OUTER JOIN clause.
 
SqlDeleteQueryBuilder & LeftOuterJoin (TableName auto joinTable, OnChainCallable const &onClauseBuilder)
 Constructs an LEFT OUTER JOIN clause with a custom ON clause.
 
SqlDeleteQueryBuilder & RightOuterJoin (TableName auto joinTable, std::string_view joinColumnName, SqlQualifiedTableColumnName onOtherColumn)
 Constructs an RIGHT OUTER JOIN clause.
 
SqlDeleteQueryBuilder & RightOuterJoin (TableName auto joinTable, std::string_view joinColumnName, std::string_view onMainTableColumn)
 Constructs an RIGHT OUTER JOIN clause.
 
SqlDeleteQueryBuilder & RightOuterJoin (TableName auto joinTable, OnChainCallable const &onClauseBuilder)
 Constructs an RIGHT OUTER JOIN clause with a custom ON clause.
 
SqlDeleteQueryBuilder & FullOuterJoin (TableName auto joinTable, std::string_view joinColumnName, SqlQualifiedTableColumnName onOtherColumn)
 Constructs an FULL OUTER JOIN clause.
 
SqlDeleteQueryBuilder & FullOuterJoin (TableName auto joinTable, std::string_view joinColumnName, std::string_view onMainTableColumn)
 Constructs an FULL OUTER JOIN clause.
 
SqlDeleteQueryBuilder & FullOuterJoin (TableName auto joinTable, OnChainCallable const &onClauseBuilder)
 Constructs an FULL OUTER JOIN clause with a custom ON clause.
 
LIGHTWEIGHT_FORCE_INLINE void AppendColumnName (ColumnName const &columnName)
 Appends a column name to the WHERE condition.
 
LIGHTWEIGHT_FORCE_INLINE void AppendLiteralValue (LiteralType const &value)
 Appends a literal value to the WHERE condition.
 
LIGHTWEIGHT_FORCE_INLINE void PopulateLiteralValueInto (LiteralType const &value, TargetType &target)
 Populates a literal value into the target string.
 
LIGHTWEIGHT_FORCE_INLINE SqlDeleteQueryBuilder & Join (JoinType joinType, TableName auto joinTable, Callable const &onClauseBuilder)
 Constructs a JOIN clause with a custom ON clause builder.
 

Detailed Description

Query builder for building DELETE FROM ... queries.

Definition at line 16 of file Delete.hpp.

Constructor & Destructor Documentation

◆ SqlDeleteQueryBuilder()

Lightweight::SqlDeleteQueryBuilder::SqlDeleteQueryBuilder ( SqlQueryFormatter const &  formatter,
std::string  table,
std::string  tableAlias,
std::vector< SqlVariant > *  inputBindings = nullptr 
)
inlineexplicitnoexcept

Constructs a DELETE query builder.

Parameters
formatterDialect the query is written in.
tableTable to delete from.
tableAliasAlias for that table, empty for none.
inputBindingsReceives the WHERE values as bound parameters instead of having them written into the query text; null keeps them inline. Values are appended, never cleared. Execute the result with SqlStatement::ExecuteWithVariants(), not ExecuteDirect(), which would leave the markers unbound. Both the vector and anything a stored std::string_view / std::u16string_view points at must outlive the execution, because the binder hands the driver that pointer directly.
Note
An explicit SqlWildcard emits its marker without recording a value here, and a WhereIn() set larger than SqlMaxBoundSetSize falls back to inline literals; either makes the marker count differ from the vector size.

Definition at line 34 of file Delete.hpp.

Member Function Documentation

◆ SearchCondition()

SqlSearchCondition & Lightweight::SqlDeleteQueryBuilder::SearchCondition ( )
inlinenoexcept

Returns the search condition for the query.

Definition at line 47 of file Delete.hpp.

◆ Formatter()

SqlQueryFormatter const & Lightweight::SqlDeleteQueryBuilder::Formatter ( ) const
inlinenoexcept

Returns the SQL query formatter.

Definition at line 54 of file Delete.hpp.

◆ ToSql()

LIGHTWEIGHT_FORCE_INLINE std::string Lightweight::SqlDeleteQueryBuilder::ToSql ( ) const
inline

Finalizes building the query as DELETE FROM ... query.

Definition at line 68 of file Delete.hpp.

References Lightweight::SqlQueryFormatter::Delete().


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