diff options
| author | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2026-05-05 12:17:58 +0100 |
|---|---|---|
| committer | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2026-05-05 12:17:58 +0100 |
| commit | f9b4422198281410218e371ffc3e1e4513a9ba7f (patch) | |
| tree | 2c29795d5334fc1bb33222feec8e9dfe2dd5d968 /src | |
| parent | b7346649926b4357b27aa81238eb34cebe39671b (diff) | |
| download | webstat-f9b4422198281410218e371ffc3e1e4513a9ba7f.tar.bz2 webstat-f9b4422198281410218e371ffc3e1e4513a9ba7f.tar.xz webstat-f9b4422198281410218e371ffc3e1e4513a9ba7f.zip | |
Add override of insert helper for tuples
When Fields... is more than a single type, returns a tuple of fields,
instead of a single value.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ingestor.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/ingestor.cpp b/src/ingestor.cpp index 971cc29..3e36d85 100644 --- a/src/ingestor.cpp +++ b/src/ingestor.cpp @@ -9,6 +9,7 @@ #include <ranges> #include <scn/scan.h> #include <selectcommand.h> +#include <selectcommandUtil.impl.h> #include <syslog.h> #include <utility> #include <zlib.h> @@ -102,6 +103,21 @@ namespace WebStat { } throw DB::NoRowsAffected {}; } + + template<typename... Fields, typename... Binds> + requires(sizeof...(Fields) > 1) + std::tuple<Fields...> + insert(auto && dbconn, const std::string & sql, const DB::CommandOptionsPtr & opts, Binds &&... binds) + { + DB::SelectCommandPtr ins = dbconn->select(sql, opts); + bindMany(ins, 0, std::forward<Binds>(binds)...); + for (auto row : ins->template as<Fields...>()) { + return [&row]<std::unsigned_integral T, T... N>(std::integer_sequence<T, N...>) { + return std::make_tuple(row.template get<N>()...); + }(std::make_integer_sequence<unsigned int, sizeof...(Fields)> {}); + } + throw DB::NoRowsAffected {}; + } } Ingestor * Ingestor::currentIngestor = nullptr; |
