Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/simdb/Exceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DBException : public std::exception
DBException() = default;

/// \brief Construct with an initial reason string.
explicit DBException(const std::string& reason) { reason_ << reason; }
explicit DBException(const std::string_view reason) { reason_ << reason; }

/// \brief Copy constructor; copies the accumulated message.
DBException(const DBException& rhs) { reason_ << rhs.reason_.str(); }
Expand Down
6 changes: 3 additions & 3 deletions include/simdb/sqlite/Connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,17 @@ class Connection : public Transaction
/// Execute the provided statement against the database
/// connection. This will validate the command, and throw
/// if this command is disallowed.
void executeCommand(const std::string& command)
void executeCommand(const std::string_view command)
{
auto rc = SQLiteReturnCode(sqlite3_exec(db_conn_, command.c_str(), nullptr, nullptr, nullptr));
auto rc = SQLiteReturnCode(sqlite3_exec(db_conn_, command.data(), nullptr, nullptr, nullptr));
if (rc)
{
throw DBException(sqlite3_errmsg(db_conn_));
}
}

/// Turn the given command into an SQL prepared statement.
SQLitePreparedStatement prepareStatement(const std::string& command)
SQLitePreparedStatement prepareStatement(const std::string_view command)
{
return SQLitePreparedStatement(db_conn_, command);
}
Expand Down
2 changes: 1 addition & 1 deletion include/simdb/sqlite/Table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace simdb {
class SqlTable
{
public:
SqlTable(const std::string& table_name) :
SqlTable(const std::string_view table_name) :
table_name_(table_name)
{
}
Expand Down
4 changes: 2 additions & 2 deletions include/simdb/sqlite/Transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ inline std::ostream& operator<<(std::ostream& os, const SQLiteReturnCode& rc)
class SQLitePreparedStatement
{
public:
SQLitePreparedStatement(sqlite3* db_conn, const std::string& cmd)
SQLitePreparedStatement(sqlite3* db_conn, const std::string_view cmd)
{
sqlite3_stmt* stmt = nullptr;
auto rc = sqlite3_prepare_v2(db_conn, cmd.c_str(), -1, &stmt, 0);
auto rc = sqlite3_prepare_v2(db_conn, cmd.data(), -1, &stmt, 0);
if (rc == SQLITE_BUSY || rc == SQLITE_LOCKED || rc == SQLITE_READONLY)
{
sqlite3_finalize(stmt);
Expand Down