22template <TableType Table,
typename Where = std::nullopt_t>
32 : table_(
std::move(table)), where_(
std::move(
where)) {}
38 ss <<
"DELETE FROM " << table_.table_name;
41 if constexpr (!std::is_same_v<Where, std::nullopt_t>) {
42 if (where_.has_value()) {
43 ss <<
" WHERE " << where_.value().to_sql();
53 std::vector<std::string> params;
56 if constexpr (!std::is_same_v<Where, std::nullopt_t>) {
57 if (where_.has_value()) {
58 auto where_params = where_.value().bind_params();
59 params.insert(params.end(), where_params.begin(), where_params.end());
70 template <ConditionExpr Condition>
71 auto where(
const Condition& cond)
const {
81 template <ColumnType Col, std::ranges::range Range>
82 requires std::convertible_to<std::ranges::range_value_t<Range>, std::string>
85 auto in_condition =
in(col_expr, values);
86 return where(in_condition);
98template <TableType Table>
Base DELETE query builder.
DeleteQuery(Table table, Where where=std::nullopt)
Constructor for the DELETE query builder.
auto where(const Condition &cond) const
Add a WHERE clause to the query.
std::string to_sql() const
Generate the SQL for this DELETE query.
auto where_in(const Col &column, const Range &values) const
Set a condition for filtering the rows to delete using IN with values.
std::vector< std::string > bind_params() const
Get the bind parameters for this DELETE query.
Represents a column in a database table.
auto in(const schema::column< TableT, Name, T, Modifiers... > &col, Range values)
Create an IN condition with type checking for columns.
auto column_ref(const Column &col)
Create a column reference expression.
auto delete_from(const Table &table)
Create a DELETE query for the specified table.