diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-01-01 19:34:49 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-01-01 19:44:46 +0000 |
commit | 19d7c80017b560645f8ad3fefeef6f11e410ecf4 (patch) | |
tree | bd677db43035a31d07c4246eab9e4f7c9518f347 | |
parent | Add method for replacing a named object added default adapter during service ... (diff) | |
download | icetray-19d7c80017b560645f8ad3fefeef6f11e410ecf4.tar.bz2 icetray-19d7c80017b560645f8ad3fefeef6f11e410ecf4.tar.xz icetray-19d7c80017b560645f8ad3fefeef6f11e410ecf4.zip |
Add sql source wrappers to get commands with options containing hash and any given optionsicetray-0.1.2
-rw-r--r-- | icetray/icetray/abstractDatabaseClient.h | 2 | ||||
-rw-r--r-- | icetray/icetray/sqlSource.h | 17 |
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); + } }; } |