userver: userver/storages/clickhouse/parameter_store.hpp Source File
Loading...
Searching...
No Matches
parameter_store.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <string_view>
7
8#include <fmt/args.h>
9#include <fmt/format.h>
10
11#include <userver/storages/clickhouse/io/impl/escape.hpp>
13
14USERVER_NAMESPACE_BEGIN
15
16namespace storages::clickhouse {
17
23class ParameterStore {
24public:
25 ParameterStore() = default;
26 ParameterStore(const ParameterStore&) = delete;
27 ParameterStore(ParameterStore&&) = default;
28 ParameterStore& operator=(const ParameterStore&) = delete;
29 ParameterStore& operator=(ParameterStore&&) = default;
30
33 template <typename T>
34 ParameterStore& PushBack(const T& param) {
35 parameters_.push_back(io::impl::Escape(param));
36 return *this;
37 }
38
40 // For internal use only
41 Query MakeQueryWithArgs(const Query& query) const {
42 // we should throw on params count mismatch
43 // TODO : https://st.yandex-team.ru/TAXICOMMON-5066
44 return Query{fmt::vformat(std::string_view{query.GetStatementView()}, parameters_), query.GetOptionalName()};
45 }
47
48private:
49 fmt::dynamic_format_arg_store<fmt::format_context> parameters_{};
50};
51
52} // namespace storages::clickhouse
53
54USERVER_NAMESPACE_END