diff --git a/include/pq/connection.hpp b/include/pq/connection.hpp index 2099b69..111a3ef 100644 --- a/include/pq/connection.hpp +++ b/include/pq/connection.hpp @@ -42,6 +42,7 @@ namespace pq { void connect ( void ); void disconnect ( void ); ResultSet query ( const std::string& parQuery ); + ResultSet query ( const char* parQuery ); std::string escaped_literal ( const std::string& parString ); std::string escaped_literal ( boost::string_ref parString ); diff --git a/src/pq/connection.cpp b/src/pq/connection.cpp index d7b9831..f83120d 100644 --- a/src/pq/connection.cpp +++ b/src/pq/connection.cpp @@ -132,7 +132,13 @@ namespace pq { } ResultSet Connection::query (const std::string& parQuery) { - ResultInfo info(PQexec(m_localData->connection, parQuery.c_str())); + assert(not parQuery.empty()); + return this->query(parQuery.c_str()); + } + + ResultSet Connection::query (const char* parQuery) { + assert(parQuery); + ResultInfo info(PQexec(m_localData->connection, parQuery)); if (not info.result) throw DatabaseException("Error running query", "Error allocating result object", __FILE__, __LINE__); const int ress = PQresultStatus(info.result.get());