summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdbpp/command_fwd.h2
-rw-r--r--libdbpp/connection.cpp2
-rw-r--r--libdbpp/connection.h8
-rw-r--r--libdbpp/unittests/mockdb.cpp6
-rw-r--r--libdbpp/unittests/mockdb.h6
5 files changed, 14 insertions, 10 deletions
diff --git a/libdbpp/command_fwd.h b/libdbpp/command_fwd.h
index 36776d2..bf7133d 100644
--- a/libdbpp/command_fwd.h
+++ b/libdbpp/command_fwd.h
@@ -8,6 +8,8 @@
namespace DB {
typedef std::map<std::string, std::string> CommandOptionsMap;
class CommandOptions;
+ typedef std::shared_ptr<CommandOptions> CommandOptionsPtr;
+ typedef std::shared_ptr<const CommandOptions> CommandOptionsCPtr;
class Command;
typedef std::shared_ptr<Command> CommandPtr;
class ModifyCommand;
diff --git a/libdbpp/connection.cpp b/libdbpp/connection.cpp
index e771854..276c4ed 100644
--- a/libdbpp/connection.cpp
+++ b/libdbpp/connection.cpp
@@ -28,7 +28,7 @@ DB::Connection::~Connection()
}
void
-DB::Connection::execute(const std::string & sql, const CommandOptions * opts)
+DB::Connection::execute(const std::string & sql, const CommandOptionsCPtr & opts)
{
modify(sql, opts)->execute(true);
}
diff --git a/libdbpp/connection.h b/libdbpp/connection.h
index 7d27a22..4a424a7 100644
--- a/libdbpp/connection.h
+++ b/libdbpp/connection.h
@@ -19,6 +19,8 @@ namespace AdHoc {
namespace DB {
class Command;
class CommandOptions;
+ typedef std::shared_ptr<CommandOptions> CommandOptionsPtr;
+ typedef std::shared_ptr<const CommandOptions> CommandOptionsCPtr;
class SelectCommand;
typedef std::shared_ptr<SelectCommand> SelectCommandPtr;
class ModifyCommand;
@@ -115,15 +117,15 @@ namespace DB {
/// @endcond
/// Straight up execute a statement (no access to result set)
- virtual void execute(const std::string & sql, const CommandOptions * = nullptr);
+ virtual void execute(const std::string & sql, const CommandOptionsCPtr & = nullptr);
/// Execute a script from a stream.
/// @param f the script.
/// @param s the location of the script.
virtual void executeScript(std::istream & f, const boost::filesystem::path & s);
/// Create a new select command with the given SQL.
- virtual SelectCommandPtr select(const std::string & sql, const CommandOptions * = nullptr) = 0;
+ virtual SelectCommandPtr select(const std::string & sql, const CommandOptionsCPtr & = nullptr) = 0;
/// Create a new modify command with the given SQL.
- virtual ModifyCommandPtr modify(const std::string & sql, const CommandOptions * = nullptr) = 0;
+ virtual ModifyCommandPtr modify(const std::string & sql, const CommandOptionsCPtr & = nullptr) = 0;
/// Begin a bulk upload operation.
/// @param table the target table.
diff --git a/libdbpp/unittests/mockdb.cpp b/libdbpp/unittests/mockdb.cpp
index 6b5a7cc..d831b57 100644
--- a/libdbpp/unittests/mockdb.cpp
+++ b/libdbpp/unittests/mockdb.cpp
@@ -38,7 +38,7 @@ MockDb::bulkUpdateStyle() const
}
void
-MockDb::execute(const std::string & sql, const DB::CommandOptions *)
+MockDb::execute(const std::string & sql, const DB::CommandOptionsCPtr &)
{
if (sql.substr(0, 3) == "Not") {
throw DB::Error();
@@ -47,13 +47,13 @@ MockDb::execute(const std::string & sql, const DB::CommandOptions *)
}
DB::SelectCommandPtr
-MockDb::select(const std::string &, const DB::CommandOptions *)
+MockDb::select(const std::string &, const DB::CommandOptionsCPtr &)
{
return nullptr;
}
DB::ModifyCommandPtr
-MockDb::modify(const std::string &, const DB::CommandOptions *)
+MockDb::modify(const std::string &, const DB::CommandOptionsCPtr &)
{
return nullptr;
}
diff --git a/libdbpp/unittests/mockdb.h b/libdbpp/unittests/mockdb.h
index 53fd451..41d63e1 100644
--- a/libdbpp/unittests/mockdb.h
+++ b/libdbpp/unittests/mockdb.h
@@ -15,9 +15,9 @@ class MockDb : public DB::Connection {
DB::BulkDeleteStyle bulkDeleteStyle() const override;
DB::BulkUpdateStyle bulkUpdateStyle() const override;
- void execute(const std::string & sql, const DB::CommandOptions *) override;
- DB::SelectCommandPtr select(const std::string &, const DB::CommandOptions *) override;
- DB::ModifyCommandPtr modify(const std::string &, const DB::CommandOptions *) override;
+ void execute(const std::string & sql, const DB::CommandOptionsCPtr &) override;
+ DB::SelectCommandPtr select(const std::string &, const DB::CommandOptionsCPtr &) override;
+ DB::ModifyCommandPtr modify(const std::string &, const DB::CommandOptionsCPtr &) override;
mutable std::vector<std::string> executed;
};