From f9b4422198281410218e371ffc3e1e4513a9ba7f Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 5 May 2026 12:17:58 +0100 Subject: 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. --- src/ingestor.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src') 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 #include #include +#include #include #include #include @@ -102,6 +103,21 @@ namespace WebStat { } throw DB::NoRowsAffected {}; } + + template + requires(sizeof...(Fields) > 1) + std::tuple + 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)...); + for (auto row : ins->template as()) { + return [&row](std::integer_sequence) { + return std::make_tuple(row.template get()...); + }(std::make_integer_sequence {}); + } + throw DB::NoRowsAffected {}; + } } Ingestor * Ingestor::currentIngestor = nullptr; -- cgit v1.3