IronQuery
A SQL-first query builder for C++
Loading...
Searching...
No Matches
update.hpp
1#pragma once
2
3#include <initializer_list>
4#include <iron_query/condition.hpp>
5#include <iron_query/expr.hpp>
6#include <iron_query/select_item.hpp>
7#include <iron_query/table.hpp>
8#include <iron_query/virtual_table.hpp>
9#include <string>
10
11namespace iron_query {
12
16class [[nodiscard]] Update final {
17public:
19 Update(const Table &tbl);
20
24 Update Set(const Expr &column, const Expr &value) &&;
25
31 Update From(const VirtualTable &tbl) &&;
32
36
40
43 Update Returning(std::initializer_list<SelectItem> items) &&;
44
46 std::string ToString() const;
47
48private:
49 std::string table_;
50 std::string set_;
51 std::string from_;
52 std::string where_;
53 std::string returning_;
54};
55
56} // namespace iron_query
A boolean-valued SQL predicate, e.g. the result of a comparison, LIKE/IN/BETWEEN/IS [NOT] NULL,...
Definition condition.hpp:25
Arbitrary SQL expression.
Definition expr.hpp:46
A single entry of a SELECT list: an expression, optionally renamed with Expr::As. Kept distinct from ...
Definition select_item.hpp:15
Table with name.
Definition table.hpp:10
Transitional representation for UPDATE query.
Definition update.hpp:16
Update Returning(SelectItem item) &&
Sets the RETURNING clause to a single entry.
Update Where(Condition exp) &&
Sets the WHERE clause.
Update Set(const Expr &column, const Expr &value) &&
Adds a column = value assignment to the SET clause.
std::string ToString() const
Update Returning(std::initializer_list< SelectItem > items) &&
Sets the RETURNING clause to a comma-separated list of entries.
Update(const Table &tbl)
Starts an UPDATE tbl query.
Update From(const VirtualTable &tbl) &&
Sets the FROM clause, so SET/WHERE expressions may reference columns of tbl. tbl may be a table,...
Any table value, including physical table, table result, materialized view, etc.
Definition virtual_table.hpp:14