summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--icetray/icetray/abstractDatabaseClient.h2
-rw-r--r--icetray/icetray/sqlSource.h17
2 files changed, 18 insertions, 1 deletions
diff --git a/icetray/icetray/abstractDatabaseClient.h b/icetray/icetray/abstractDatabaseClient.h
index 50a7cda..4c65ff7 100644
--- a/icetray/icetray/abstractDatabaseClient.h
+++ b/icetray/icetray/abstractDatabaseClient.h
@@ -18,7 +18,7 @@ namespace IceTray {
fetch(const SqlSource & sql, const Params & ... params)
{
auto c = db->get();
- auto s = c->select(sql.getSql());
+ auto s = sql.select(c.get());
bind(0, s.get(), params...);
return Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, Domain>(*s);
}
diff --git a/icetray/icetray/sqlSource.h b/icetray/icetray/sqlSource.h
index 25ed933..a0e8ea1 100644
--- a/icetray/icetray/sqlSource.h
+++ b/icetray/icetray/sqlSource.h
@@ -4,6 +4,9 @@
#include <functional>
#include <string>
#include <visibility.h>
+#include <connection.h>
+#include <modifycommand.h>
+#include <selectcommand.h>
namespace IceTray {
class DLL_PUBLIC SqlSource {
@@ -12,6 +15,20 @@ namespace IceTray {
virtual const std::string & getSql() const = 0;
virtual std::size_t getSqlHash() const;
+
+ template<typename OptsType = DB::CommandOptions, typename ... Opts>
+ DB::ModifyCommandPtr modify(DB::Connection * db, const Opts & ... opts) const
+ {
+ OptsType o(getSqlHash(), opts...);
+ return db->modify(getSql(), &o);
+ }
+
+ template<typename OptsType = DB::CommandOptions, typename ... Opts>
+ DB::SelectCommandPtr select(DB::Connection * db, const Opts & ... opts) const
+ {
+ OptsType o(getSqlHash(), opts...);
+ return db->select(getSql(), &o);
+ }
};
}