diff --git a/rdbms/Stmt.cpp b/rdbms/Stmt.cpp index cd949b69930d1c7b45d3dc3d630014e08fc63cf8..1278189c39df651e07bb01071bf14efc2b511cd6 100644 --- a/rdbms/Stmt.cpp +++ b/rdbms/Stmt.cpp @@ -121,11 +121,7 @@ uint32_t Stmt::getParamIdx(const std::string ¶mName) const { //----------------------------------------------------------------------------- void Stmt::bindUint8(const std::string ¶mName, const uint8_t paramValue) { try { - if(nullptr != m_stmt) { - return m_stmt->bindUint8(paramName, paramValue); - } else { - throw exception::Exception("Stmt does not contain a cached statement"); - } + bindOptionalUint8(paramName, paramValue); } catch(exception::Exception &ex) { ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); throw; @@ -153,11 +149,7 @@ void Stmt::bindOptionalUint8(const std::string ¶mName, const optional<uint8_ //----------------------------------------------------------------------------- void Stmt::bindUint16(const std::string ¶mName, const uint16_t paramValue) { try { - if(nullptr != m_stmt) { - return m_stmt->bindUint16(paramName, paramValue); - } else { - throw exception::Exception("Stmt does not contain a cached statement"); - } + bindOptionalUint16(paramName, paramValue); } catch(exception::Exception &ex) { ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); throw; @@ -185,11 +177,7 @@ void Stmt::bindOptionalUint16(const std::string ¶mName, const optional<uint1 //----------------------------------------------------------------------------- void Stmt::bindUint32(const std::string ¶mName, const uint32_t paramValue) { try { - if(nullptr != m_stmt) { - return m_stmt->bindUint32(paramName, paramValue); - } else { - throw exception::Exception("Stmt does not contain a cached statement"); - } + bindOptionalUint32(paramName, paramValue); } catch(exception::Exception &ex) { ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); throw; @@ -217,11 +205,7 @@ void Stmt::bindOptionalUint32(const std::string ¶mName, const optional<uint3 //----------------------------------------------------------------------------- void Stmt::bindUint64(const std::string ¶mName, const uint64_t paramValue) { try { - if(nullptr != m_stmt) { - return m_stmt->bindUint64(paramName, paramValue); - } else { - throw exception::Exception("Stmt does not contain a cached statement"); - } + bindOptionalUint64(paramName, paramValue); } catch(exception::Exception &ex) { ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); throw; @@ -249,11 +233,7 @@ void Stmt::bindOptionalUint64(const std::string ¶mName, const optional<uint6 //----------------------------------------------------------------------------- void Stmt::bindDouble(const std::string ¶mName, const double paramValue) { try { - if(nullptr != m_stmt) { - return m_stmt->bindDouble(paramName, paramValue); - } else { - throw exception::Exception("Stmt does not contain a cached statement"); - } + bindOptionalDouble(paramName, paramValue); } catch(exception::Exception &ex) { ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); throw; @@ -281,11 +261,7 @@ void Stmt::bindOptionalDouble(const std::string ¶mName, const optional<doubl //----------------------------------------------------------------------------- void Stmt::bindBool(const std::string ¶mName, const bool paramValue) { try { - if(nullptr != m_stmt) { - return m_stmt->bindBool(paramName, paramValue); - } else { - throw exception::Exception("Stmt does not contain a cached statement"); - } + bindOptionalBool(paramName, paramValue); } catch(exception::Exception &ex) { ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); throw; @@ -329,11 +305,7 @@ void Stmt::bindBlob(const std::string ¶mName, const std::string ¶mValue) //----------------------------------------------------------------------------- void Stmt::bindString(const std::string ¶mName, const std::string ¶mValue) { try { - if(nullptr != m_stmt) { - return m_stmt->bindString(paramName, paramValue); - } else { - throw exception::Exception("Stmt does not contain a cached statement"); - } + bindOptionalString(paramName, paramValue); } catch(exception::Exception &ex) { ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); throw; diff --git a/rdbms/wrapper/MysqlConn.cpp b/rdbms/wrapper/MysqlConn.cpp index b82ef563a7f000e61909c689ebc8306203f507c1..47b347f005c3d74c5b890da11d1896d2d297ac0e 100644 --- a/rdbms/wrapper/MysqlConn.cpp +++ b/rdbms/wrapper/MysqlConn.cpp @@ -219,7 +219,7 @@ std::map<std::string, std::string> MysqlConn::getColumns(const std::string &tabl "TABLE_NAME = :TABLE_NAME"; auto stmt = createStmt(sql); - stmt->bindString(":TABLE_NAME", tableName); + stmt->bindOptionalString(":TABLE_NAME", tableName); auto rset = stmt->executeQuery(); while (rset->next()) { auto name = rset->columnOptionalString("COLUMN_NAME"); diff --git a/rdbms/wrapper/MysqlStmt.cpp b/rdbms/wrapper/MysqlStmt.cpp index 3bb54a9619ff16623e1054c381ca710d07641cc7..249ffbf424b15242021d53008cb11bf6231362e7 100644 --- a/rdbms/wrapper/MysqlStmt.cpp +++ b/rdbms/wrapper/MysqlStmt.cpp @@ -170,18 +170,6 @@ MYSQL_STMT *MysqlStmt::get() const { return m_stmt; } -//------------------------------------------------------------------------------ -// bindUint8 -//------------------------------------------------------------------------------ -void MysqlStmt::bindUint8(const std::string ¶mName, const uint8_t paramValue) { - try { - bindOptionalUint8(paramName, paramValue); - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - throw; - } -} - //------------------------------------------------------------------------------ // bindOptionalUint8 //------------------------------------------------------------------------------ @@ -216,18 +204,6 @@ void MysqlStmt::bindOptionalUint8(const std::string ¶mName, const optional<u } } -//------------------------------------------------------------------------------ -// bindUint16 -//------------------------------------------------------------------------------ -void MysqlStmt::bindUint16(const std::string ¶mName, const uint16_t paramValue) { - try { - bindOptionalUint16(paramName, paramValue); - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - throw; - } -} - //------------------------------------------------------------------------------ // bindOptionalUint16 //------------------------------------------------------------------------------ @@ -262,18 +238,6 @@ void MysqlStmt::bindOptionalUint16(const std::string ¶mName, const optional< } } -//------------------------------------------------------------------------------ -// bindUint32 -//------------------------------------------------------------------------------ -void MysqlStmt::bindUint32(const std::string ¶mName, const uint32_t paramValue) { - try { - bindOptionalUint32(paramName, paramValue); - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - throw; - } -} - //------------------------------------------------------------------------------ // bindOptionalUint32 //------------------------------------------------------------------------------ @@ -308,18 +272,6 @@ void MysqlStmt::bindOptionalUint32(const std::string ¶mName, const optional< } } -//------------------------------------------------------------------------------ -// bindUint64 -//------------------------------------------------------------------------------ -void MysqlStmt::bindUint64(const std::string ¶mName, const uint64_t paramValue) { - try { - bindOptionalUint64(paramName, paramValue); - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - throw; - } -} - //------------------------------------------------------------------------------ // bindOptionalUint64 //------------------------------------------------------------------------------ @@ -354,17 +306,6 @@ void MysqlStmt::bindOptionalUint64(const std::string ¶mName, const optional< } } -//------------------------------------------------------------------------------ -// bindDouble -//------------------------------------------------------------------------------ -void MysqlStmt::bindDouble(const std::string ¶mName, const double paramValue) { - try { - bindOptionalDouble(paramName, paramValue); - } catch(exception::Exception &ex) { - throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - } -} - //------------------------------------------------------------------------------ // bindOptionalDouble //------------------------------------------------------------------------------ @@ -407,17 +348,6 @@ void MysqlStmt::bindBlob(const std::string ¶mName, const std::string ¶mV } } -//------------------------------------------------------------------------------ -// bindString -//------------------------------------------------------------------------------ -void MysqlStmt::bindString(const std::string ¶mName, const std::string ¶mValue) { - try { - bindOptionalString(paramName, paramValue); - } catch(exception::Exception &ex) { - throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - } -} - //------------------------------------------------------------------------------ // bindOptionalString //------------------------------------------------------------------------------ diff --git a/rdbms/wrapper/MysqlStmt.hpp b/rdbms/wrapper/MysqlStmt.hpp index fd8842df2854690328009626c1a7b79ee29e8711..ee2ff15a578e414c351bad0aae3867f3215b3c84 100644 --- a/rdbms/wrapper/MysqlStmt.hpp +++ b/rdbms/wrapper/MysqlStmt.hpp @@ -84,14 +84,6 @@ public: */ MYSQL_STMT *get() const; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindUint8(const std::string ¶mName, const uint8_t paramValue) override; - /** * Binds an SQL parameter. * @@ -100,14 +92,6 @@ public: */ void bindOptionalUint8(const std::string ¶mName, const optional<uint8_t> ¶mValue) override; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindUint16(const std::string ¶mName, const uint16_t paramValue) override; - /** * Binds an SQL parameter. * @@ -116,14 +100,6 @@ public: */ void bindOptionalUint16(const std::string ¶mName, const optional<uint16_t> ¶mValue) override; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindUint32(const std::string ¶mName, const uint32_t paramValue) override; - /** * Binds an SQL parameter. * @@ -132,14 +108,6 @@ public: */ void bindOptionalUint32(const std::string ¶mName, const optional<uint32_t> ¶mValue) override; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindUint64(const std::string ¶mName, const uint64_t paramValue) override; - /** * Binds an SQL parameter. * @@ -148,14 +116,6 @@ public: */ void bindOptionalUint64(const std::string ¶mName, const optional<uint64_t> ¶mValue) override; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindDouble(const std::string ¶mName, const double paramValue) override; - /** * Binds an SQL parameter. * @@ -172,19 +132,7 @@ public: */ void bindBlob(const std::string ¶mName, const std::string ¶mValue) override; - /** - * Binds an SQL parameter of type string. - * - * Please note that this method will throw an exception if the string - * parameter is empty. If a null value is to be bound then the - * bindOptionalString() method should be used. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindString(const std::string ¶mName, const std::string ¶mValue) override; - - /** + /** * Binds an SQL parameter of type optional-string. * * Please note that this method will throw an exception if the optional string @@ -219,8 +167,6 @@ public: Mysql::Placeholder* columnHolder(const std::string &colName) const; - -private: private: /** diff --git a/rdbms/wrapper/OcciConn.cpp b/rdbms/wrapper/OcciConn.cpp index f21a20a60da3784161759a12f28a5a0f98332a08..2246b1a210738b0d47c76b5e15e7a62f45080acc 100644 --- a/rdbms/wrapper/OcciConn.cpp +++ b/rdbms/wrapper/OcciConn.cpp @@ -177,7 +177,7 @@ std::map<std::string, std::string> OcciConn::getColumns(const std::string &table "TABLE_NAME = :TABLE_NAME"; auto stmt = createStmt(sql); - stmt->bindString(":TABLE_NAME", tableName); + stmt->bindOptionalString(":TABLE_NAME", tableName); auto rset = stmt->executeQuery(); while (rset->next()) { auto name = rset->columnOptionalString("COLUMN_NAME"); diff --git a/rdbms/wrapper/OcciStmt.cpp b/rdbms/wrapper/OcciStmt.cpp index e8e5e1bb112f20368dd3065e965392c8c33f0e27..44d4854a76908203d21bb6e094ebc72e3d884341 100644 --- a/rdbms/wrapper/OcciStmt.cpp +++ b/rdbms/wrapper/OcciStmt.cpp @@ -87,18 +87,6 @@ void OcciStmt::close() { } } -//------------------------------------------------------------------------------ -// bindUint8 -//------------------------------------------------------------------------------ -void OcciStmt::bindUint8(const std::string ¶mName, const uint8_t paramValue) { - try { - bindOptionalUint8(paramName, paramValue); - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - throw; - } -} - //------------------------------------------------------------------------------ // bindOptionalUint8 //------------------------------------------------------------------------------ @@ -111,18 +99,6 @@ void OcciStmt::bindOptionalUint8(const std::string ¶mName, const optional<ui } } -//------------------------------------------------------------------------------ -// bindUint16 -//------------------------------------------------------------------------------ -void OcciStmt::bindUint16(const std::string ¶mName, const uint16_t paramValue) { - try { - bindOptionalUint16(paramName, paramValue); - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - throw; - } -} - //------------------------------------------------------------------------------ // bindOptionalUint16 //------------------------------------------------------------------------------ @@ -135,18 +111,6 @@ void OcciStmt::bindOptionalUint16(const std::string ¶mName, const optional<u } } -//------------------------------------------------------------------------------ -// bindUint32 -//------------------------------------------------------------------------------ -void OcciStmt::bindUint32(const std::string ¶mName, const uint32_t paramValue) { - try { - bindOptionalUint32(paramName, paramValue); - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - throw; - } -} - //------------------------------------------------------------------------------ // bindOptionalUint32 //------------------------------------------------------------------------------ @@ -159,18 +123,6 @@ void OcciStmt::bindOptionalUint32(const std::string ¶mName, const optional<u } } -//------------------------------------------------------------------------------ -// bindUint64 -//------------------------------------------------------------------------------ -void OcciStmt::bindUint64(const std::string ¶mName, const uint64_t paramValue) { - try { - bindOptionalUint64(paramName, paramValue); - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - throw; - } -} - //------------------------------------------------------------------------------ // bindOptionalUint64 //------------------------------------------------------------------------------ @@ -190,17 +142,6 @@ void OcciStmt::bindBlob(const std::string ¶mName, const std::string ¶mVa throw exception::Exception("OcciStmt::bindBlob not implemented."); } -//------------------------------------------------------------------------------ -// bindDouble -//------------------------------------------------------------------------------ -void OcciStmt::bindDouble(const std::string ¶mName, const double paramValue) { - try { - bindOptionalDouble(paramName, paramValue); - } catch(exception::Exception &ex) { - throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - } -} - //------------------------------------------------------------------------------ // bindOptionalDouble //------------------------------------------------------------------------------ @@ -222,17 +163,6 @@ void OcciStmt::bindOptionalDouble(const std::string ¶mName, const optional<d } } -//------------------------------------------------------------------------------ -// bind -//------------------------------------------------------------------------------ -void OcciStmt::bindString(const std::string ¶mName, const std::string ¶mValue) { - try { - bindOptionalString(paramName, paramValue); - } catch(exception::Exception &ex) { - throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - } -} - //------------------------------------------------------------------------------ // bindOptionalString //------------------------------------------------------------------------------ diff --git a/rdbms/wrapper/OcciStmt.hpp b/rdbms/wrapper/OcciStmt.hpp index 4b73c4ca6cc58152961247ee911f4f1b2dbf86fb..613f165c5ec247b02abc09eb8f08bcd9f58d3b4f 100644 --- a/rdbms/wrapper/OcciStmt.hpp +++ b/rdbms/wrapper/OcciStmt.hpp @@ -81,14 +81,6 @@ public: */ void close() override; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindUint8(const std::string ¶mName, const uint8_t paramValue) override; - /** * Binds an SQL parameter. * @@ -97,14 +89,6 @@ public: */ void bindOptionalUint8(const std::string ¶mName, const optional<uint8_t> ¶mValue) override; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindUint16(const std::string ¶mName, const uint16_t paramValue) override; - /** * Binds an SQL parameter. * @@ -113,14 +97,6 @@ public: */ void bindOptionalUint16(const std::string ¶mName, const optional<uint16_t> ¶mValue) override; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindUint32(const std::string ¶mName, const uint32_t paramValue) override; - /** * Binds an SQL parameter. * @@ -129,14 +105,6 @@ public: */ void bindOptionalUint32(const std::string ¶mName, const optional<uint32_t> ¶mValue) override; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindUint64(const std::string ¶mName, const uint64_t paramValue) override; - /** * Binds an SQL parameter. * @@ -145,14 +113,6 @@ public: */ void bindOptionalUint64(const std::string ¶mName, const optional<uint64_t> ¶mValue) override; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindDouble(const std::string ¶mName, const double paramValue) override; - /** * Binds an SQL parameter. * @@ -169,18 +129,6 @@ public: */ void bindBlob(const std::string ¶mName, const std::string ¶mValue) override; - /** - * Binds an SQL parameter of type string. - * - * Please note that this method will throw an exception if the string - * parameter is empty. If a null value is to be bound then the - * bindOptionalString() method should be used. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindString(const std::string ¶mName, const std::string ¶mValue) override; - /** * Binds an SQL parameter of type optional-string. * diff --git a/rdbms/wrapper/PostgresConn.cpp b/rdbms/wrapper/PostgresConn.cpp index e27ee6792f14e7e0b40beb5de3b21b9c5fced5c7..bcd4dff4b491c5fce06ccf1e5e15fdacb710f06e 100644 --- a/rdbms/wrapper/PostgresConn.cpp +++ b/rdbms/wrapper/PostgresConn.cpp @@ -215,7 +215,7 @@ std::map<std::string, std::string> PostgresConn::getColumns(const std::string &t "TABLE_NAME = :TABLE_NAME"; auto stmt = createStmt(sql); - stmt->bindString(":TABLE_NAME", lowercaseTableName); + stmt->bindOptionalString(":TABLE_NAME", lowercaseTableName); auto rset = stmt->executeQuery(); while (rset->next()) { auto name = rset->columnOptionalString("COLUMN_NAME"); diff --git a/rdbms/wrapper/PostgresStmt.cpp b/rdbms/wrapper/PostgresStmt.cpp index 745c6d35761100171b40dcc7431817e9d46d7802..1ca753d2acff0a129638737f8da2079c26261f46 100644 --- a/rdbms/wrapper/PostgresStmt.cpp +++ b/rdbms/wrapper/PostgresStmt.cpp @@ -154,78 +154,11 @@ void PostgresStmt::bindOptionalUint64(const std::string ¶mName, const option } } -void PostgresStmt::bindBlob(const std::string ¶mName, const std::string ¶mValue) { - throw exception::Exception("PostgresStmt::bindBlob not implemented."); -} - -//------------------------------------------------------------------------------ -// bindString -//------------------------------------------------------------------------------ -void PostgresStmt::bindString(const std::string ¶mName, const std::string ¶mValue) { - try { - bindOptionalString(paramName, paramValue); - } catch(exception::Exception &ex) { - throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - } -} - -//------------------------------------------------------------------------------ -// bindUint8 -//------------------------------------------------------------------------------ -void PostgresStmt::bindUint8(const std::string ¶mName, const uint8_t paramValue) { - try { - bindOptionalUint8(paramName, paramValue); - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - throw; - } -} - -//------------------------------------------------------------------------------ -// bindUint16 -//------------------------------------------------------------------------------ -void PostgresStmt::bindUint16(const std::string ¶mName, const uint16_t paramValue) { - try { - bindOptionalUint16(paramName, paramValue); - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - throw; - } -} - -//------------------------------------------------------------------------------ -// bindUint32 -//------------------------------------------------------------------------------ -void PostgresStmt::bindUint32(const std::string ¶mName, const uint32_t paramValue) { - try { - bindOptionalUint32(paramName, paramValue); - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - throw; - } -} - -//------------------------------------------------------------------------------ -// bindUint64 //------------------------------------------------------------------------------ -void PostgresStmt::bindUint64(const std::string ¶mName, const uint64_t paramValue) { - try { - bindOptionalUint64(paramName, paramValue); - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - throw; - } -} - +// bindBlob //------------------------------------------------------------------------------ -// bindDouble -//------------------------------------------------------------------------------ -void PostgresStmt::bindDouble(const std::string ¶mName, const double paramValue) { - try { - bindOptionalDouble(paramName, paramValue); - } catch(exception::Exception &ex) { - throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - } +void PostgresStmt::bindBlob(const std::string ¶mName, const std::string ¶mValue) { + throw exception::Exception("PostgresStmt::bindBlob not implemented."); } //------------------------------------------------------------------------------ diff --git a/rdbms/wrapper/PostgresStmt.hpp b/rdbms/wrapper/PostgresStmt.hpp index 26d167aa0a30e68e31331a11670c49f3ab631159..f9e4b80e462915ba729f3b4ab03f7a5e55777dff 100644 --- a/rdbms/wrapper/PostgresStmt.hpp +++ b/rdbms/wrapper/PostgresStmt.hpp @@ -116,58 +116,6 @@ public: */ void bindBlob(const std::string ¶mName, const std::string ¶mValue) override; - /** - * Binds an SQL parameter of type string. - * - * Please note that this method will throw an exception if the string - * parameter is empty. If a null value is to be bound then the - * bindOptionalString() method should be used. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindString(const std::string ¶mName, const std::string ¶mValue) override; - - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindUint8(const std::string ¶mName, const uint8_t paramValue) override; - - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindUint16(const std::string ¶mName, const uint16_t paramValue) override; - - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindUint32(const std::string ¶mName, const uint32_t paramValue) override; - - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindUint64(const std::string ¶mName, const uint64_t paramValue) override; - - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindDouble(const std::string ¶mName, const double paramValue) override; - /** * Binds an SQL parameter. * diff --git a/rdbms/wrapper/PostgresStmtTest.cpp b/rdbms/wrapper/PostgresStmtTest.cpp index 812a70201e44edcc34a976d4a84ab7248db9b859..48a9001c7b6a01aa4afc98aa04a94ab495dda0e9 100644 --- a/rdbms/wrapper/PostgresStmtTest.cpp +++ b/rdbms/wrapper/PostgresStmtTest.cpp @@ -250,9 +250,9 @@ TEST_F(DISABLED_cta_rdbms_wrapper_PostgresStmtTest, insert_with_bind) { ":COL2," ":COL3);"; auto stmt = m_conn->createStmt(sql); - stmt->bindString(":COL1", "one"); - stmt->bindString(":COL2", "two"); - stmt->bindUint64(":COL3", 3); + stmt->bindOptionalString(":COL1", std::string("one")); + stmt->bindOptionalString(":COL2", std::string("two")); + stmt->bindOptionalUint64(":COL3", 3); stmt->executeNonQuery(); } @@ -402,7 +402,7 @@ TEST_F(DISABLED_cta_rdbms_wrapper_PostgresStmtTest, executeNonQuery_insert_viola "VALUES(" ":COL1);"; auto stmt = conn.createStmt(sql); - stmt->bindUint64(":COL1", 1); + stmt->bindOptionalUint64(":COL1", 1); stmt->executeNonQuery(); } @@ -414,7 +414,7 @@ TEST_F(DISABLED_cta_rdbms_wrapper_PostgresStmtTest, executeNonQuery_insert_viola "VALUES(" ":COL1);"; auto stmt = conn.createStmt(sql); - stmt->bindUint64(":COL1", 1); + stmt->bindOptionalUint64(":COL1", 1); ASSERT_THROW(stmt->executeNonQuery(), exception::Exception); } } @@ -445,7 +445,7 @@ TEST_F(DISABLED_cta_rdbms_wrapper_PostgresStmtTest, executeQuery_insert_violatin "VALUES(" ":COL1);"; auto stmt = m_conn->createStmt(sql); - stmt->bindUint64(":COL1", 1); + stmt->bindOptionalUint64(":COL1", 1); stmt->executeNonQuery(); } @@ -457,7 +457,7 @@ TEST_F(DISABLED_cta_rdbms_wrapper_PostgresStmtTest, executeQuery_insert_violatin "VALUES(" ":COL1);"; auto stmt = m_conn->createStmt(sql); - stmt->bindUint64(":COL1", 1); + stmt->bindOptionalUint64(":COL1", 1); auto rset = stmt->executeQuery(); ASSERT_THROW(rset->next(), exception::Exception); } @@ -489,7 +489,7 @@ TEST_F(DISABLED_cta_rdbms_wrapper_PostgresStmtTest, insert_with_large_uint64) { "VALUES(" ":COL1);"; auto stmt = m_conn->createStmt(sql); - stmt->bindUint64(":COL1", val); + stmt->bindOptionalUint64(":COL1", val); stmt->executeNonQuery(); } @@ -664,8 +664,8 @@ TEST_F(DISABLED_cta_rdbms_wrapper_PostgresStmtTest, nbaffected) { "UPDATE TEST SET COL1=:NEWVAL WHERE COL1=:OLDVAL"; auto stmt = m_conn->createStmt(sql); - stmt->bindString(":NEWVAL", "val3"); - stmt->bindString(":OLDVAL", "val1"); + stmt->bindOptionalString(":NEWVAL", std::string("val3")); + stmt->bindOptionalString(":OLDVAL", std::string("val1")); stmt->executeNonQuery(); ASSERT_EQ(2, stmt->getNbAffectedRows()); } diff --git a/rdbms/wrapper/SqliteConn.cpp b/rdbms/wrapper/SqliteConn.cpp index 0b230de140033fcf964bb14412a3ba3db45f2149..2c2465a3dfd51c7b5e7888ceabda95c71c20de09 100644 --- a/rdbms/wrapper/SqliteConn.cpp +++ b/rdbms/wrapper/SqliteConn.cpp @@ -252,7 +252,7 @@ std::map<std::string, std::string> SqliteConn::getColumns(const std::string &tab "BLOB"; auto stmt = createStmt(sql); - stmt->bindString(":TABLE_NAME", tableName); + stmt->bindOptionalString(":TABLE_NAME", tableName); auto rset = stmt->executeQuery(); if (rset->next()) { auto tableSql = rset->columnOptionalString("SQL").value(); diff --git a/rdbms/wrapper/SqliteStmt.cpp b/rdbms/wrapper/SqliteStmt.cpp index 305214eace7495212f19e57bb2bd2c5d0b7af004..09b42c58ea31fb8e7a6561af675a3c918c51b7d7 100644 --- a/rdbms/wrapper/SqliteStmt.cpp +++ b/rdbms/wrapper/SqliteStmt.cpp @@ -149,18 +149,6 @@ sqlite3_stmt *SqliteStmt::get() const { return m_stmt; } -//------------------------------------------------------------------------------ -// bindUint8 -//------------------------------------------------------------------------------ -void SqliteStmt::bindUint8(const std::string ¶mName, const uint8_t paramValue) { - try { - bindOptionalUint8(paramName, paramValue); - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - throw; - } -} - //------------------------------------------------------------------------------ // bindOptionalUint8 //------------------------------------------------------------------------------ @@ -182,18 +170,6 @@ void SqliteStmt::bindOptionalUint8(const std::string ¶mName, const optional< } } -//------------------------------------------------------------------------------ -// bindUint16 -//------------------------------------------------------------------------------ -void SqliteStmt::bindUint16(const std::string ¶mName, const uint16_t paramValue) { - try { - bindOptionalUint16(paramName, paramValue); - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - throw; - } -} - //------------------------------------------------------------------------------ // bindOptionalUint16 //------------------------------------------------------------------------------ @@ -215,18 +191,6 @@ void SqliteStmt::bindOptionalUint16(const std::string ¶mName, const optional } } -//------------------------------------------------------------------------------ -// bindUint32 -//------------------------------------------------------------------------------ -void SqliteStmt::bindUint32(const std::string ¶mName, const uint32_t paramValue) { - try { - bindOptionalUint32(paramName, paramValue); - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - throw; - } -} - //------------------------------------------------------------------------------ // bindOptionalUint32 //------------------------------------------------------------------------------ @@ -248,18 +212,6 @@ void SqliteStmt::bindOptionalUint32(const std::string ¶mName, const optional } } -//------------------------------------------------------------------------------ -// bindUint64 -//------------------------------------------------------------------------------ -void SqliteStmt::bindUint64(const std::string ¶mName, const uint64_t paramValue) { - try { - bindOptionalUint64(paramName, paramValue); - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - throw; - } -} - //------------------------------------------------------------------------------ // bindOptionalUint64 //------------------------------------------------------------------------------ @@ -281,17 +233,6 @@ void SqliteStmt::bindOptionalUint64(const std::string ¶mName, const optional } } -//------------------------------------------------------------------------------ -// bindDouble -//------------------------------------------------------------------------------ -void SqliteStmt::bindDouble(const std::string ¶mName, const double paramValue) { - try { - bindOptionalDouble(paramName, paramValue); - } catch(exception::Exception &ex) { - throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - } -} - //------------------------------------------------------------------------------ // bindOptionalDouble //------------------------------------------------------------------------------ @@ -313,6 +254,9 @@ void SqliteStmt::bindOptionalDouble(const std::string ¶mName, const optional } } +//------------------------------------------------------------------------------ +// bindBlob +//------------------------------------------------------------------------------ void SqliteStmt::bindBlob(const std::string ¶mName, const std::string ¶mValue) { try { const unsigned int paramIdx = getParamIdx(paramName); @@ -328,17 +272,6 @@ void SqliteStmt::bindBlob(const std::string ¶mName, const std::string ¶m } } -//------------------------------------------------------------------------------ -// bindString -//------------------------------------------------------------------------------ -void SqliteStmt::bindString(const std::string ¶mName, const std::string ¶mValue) { - try { - bindOptionalString(paramName, paramValue); - } catch(exception::Exception &ex) { - throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - } -} - //------------------------------------------------------------------------------ // bindOptionalString //------------------------------------------------------------------------------ diff --git a/rdbms/wrapper/SqliteStmt.hpp b/rdbms/wrapper/SqliteStmt.hpp index 3213cd090bb79bac0b941d86ac38afd881760378..4ab98cd947616fbdff6f41286af20db144c73eba 100644 --- a/rdbms/wrapper/SqliteStmt.hpp +++ b/rdbms/wrapper/SqliteStmt.hpp @@ -75,14 +75,6 @@ public: */ sqlite3_stmt *get() const; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindUint8(const std::string ¶mName, const uint8_t paramValue) override; - /** * Binds an SQL parameter. * @@ -91,14 +83,6 @@ public: */ void bindOptionalUint8(const std::string ¶mName, const optional<uint8_t> ¶mValue) override; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindUint16(const std::string ¶mName, const uint16_t paramValue) override; - /** * Binds an SQL parameter. * @@ -107,14 +91,6 @@ public: */ void bindOptionalUint16(const std::string ¶mName, const optional<uint16_t> ¶mValue) override; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindUint32(const std::string ¶mName, const uint32_t paramValue) override; - /** * Binds an SQL parameter. * @@ -123,14 +99,6 @@ public: */ void bindOptionalUint32(const std::string ¶mName, const optional<uint32_t> ¶mValue) override; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindUint64(const std::string ¶mName, const uint64_t paramValue) override; - /** * Binds an SQL parameter. * @@ -139,14 +107,6 @@ public: */ void bindOptionalUint64(const std::string ¶mName, const optional<uint64_t> ¶mValue) override; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindDouble(const std::string ¶mName, const double paramValue) override; - /** * Binds an SQL parameter. * @@ -163,18 +123,6 @@ public: */ void bindBlob(const std::string ¶mName, const std::string ¶mValue) override; - /** - * Binds an SQL parameter of type string. - * - * Please note that this method will throw an exception if the string - * parameter is empty. If a null value is to be bound then the - * bindOptionalString() method should be used. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindString(const std::string ¶mName, const std::string ¶mValue) override; - /** * Binds an SQL parameter of type optional-string. * diff --git a/rdbms/wrapper/SqliteStmtTest.cpp b/rdbms/wrapper/SqliteStmtTest.cpp index 6f286f530286dd14062bdce40a8d25853cc1c79f..95a285dbcbf72c324b0a9f3598abdca8cfdf895b 100644 --- a/rdbms/wrapper/SqliteStmtTest.cpp +++ b/rdbms/wrapper/SqliteStmtTest.cpp @@ -266,9 +266,9 @@ TEST_F(cta_rdbms_wrapper_SqliteStmtTest, insert_with_bind) { ":COL2," ":COL3);"; auto stmt = conn.createStmt(sql); - stmt->bindString(":COL1", "one"); - stmt->bindString(":COL2", "two"); - stmt->bindUint64(":COL3", 3); + stmt->bindOptionalString(":COL1", std::string("one")); + stmt->bindOptionalString(":COL2", std::string("two")); + stmt->bindOptionalUint64(":COL3", 3); stmt->executeNonQuery(); } @@ -390,7 +390,7 @@ TEST_F(cta_rdbms_wrapper_SqliteStmtTest, executeNonQuery_insert_violating_primar "VALUES(" ":COL1);"; auto stmt = conn.createStmt(sql); - stmt->bindUint64(":COL1", 1); + stmt->bindOptionalUint64(":COL1", 1); stmt->executeNonQuery(); } @@ -402,7 +402,7 @@ TEST_F(cta_rdbms_wrapper_SqliteStmtTest, executeNonQuery_insert_violating_primar "VALUES(" ":COL1);"; auto stmt = conn.createStmt(sql); - stmt->bindUint64(":COL1", 1); + stmt->bindOptionalUint64(":COL1", 1); ASSERT_THROW(stmt->executeNonQuery(), PrimaryKeyError); } } @@ -437,7 +437,7 @@ TEST_F(cta_rdbms_wrapper_SqliteStmtTest, executeQuery_insert_violating_primary_k "VALUES(" ":COL1);"; auto stmt = conn.createStmt(sql); - stmt->bindUint64(":COL1", 1); + stmt->bindOptionalUint64(":COL1", 1); stmt->executeNonQuery(); } @@ -449,7 +449,7 @@ TEST_F(cta_rdbms_wrapper_SqliteStmtTest, executeQuery_insert_violating_primary_k "VALUES(" ":COL1);"; auto stmt = conn.createStmt(sql); - stmt->bindUint64(":COL1", 1); + stmt->bindOptionalUint64(":COL1", 1); auto rset = stmt->executeQuery(); ASSERT_THROW(rset->next(), PrimaryKeyError); } diff --git a/rdbms/wrapper/StmtWrapper.cpp b/rdbms/wrapper/StmtWrapper.cpp index fa448244629bd916a4b7d55ff1ab664cf1419400..7a4bde42c802ea0be6b33cb9371fcb2e58a40955 100644 --- a/rdbms/wrapper/StmtWrapper.cpp +++ b/rdbms/wrapper/StmtWrapper.cpp @@ -58,13 +58,6 @@ std::string StmtWrapper::getSqlForException(const std::string::size_type maxSqlL return rdbms::getSqlForException(m_sql, maxSqlLenInExceptions); } -//------------------------------------------------------------------------------ -// bindBool -//------------------------------------------------------------------------------ -void StmtWrapper::bindBool(const std::string ¶mName, const bool paramValue) { - bindOptionalBool(paramName, paramValue); -} - //------------------------------------------------------------------------------ // bindOptionalBool //------------------------------------------------------------------------------ diff --git a/rdbms/wrapper/StmtWrapper.hpp b/rdbms/wrapper/StmtWrapper.hpp index f5c54ebd60142932c57f3bec65d04f13482cfe9e..15827d785900d6561437398a8e6f4409da01713b 100644 --- a/rdbms/wrapper/StmtWrapper.hpp +++ b/rdbms/wrapper/StmtWrapper.hpp @@ -95,14 +95,6 @@ public: */ uint32_t getParamIdx(const std::string ¶mName) const; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - virtual void bindUint8(const std::string ¶mName, const uint8_t paramValue) = 0; - /** * Binds an SQL parameter. * @@ -111,14 +103,6 @@ public: */ virtual void bindOptionalUint8(const std::string ¶mName, const optional<uint8_t> ¶mValue) = 0; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - virtual void bindUint16(const std::string ¶mName, const uint16_t paramValue) = 0; - /** * Binds an SQL parameter. * @@ -127,14 +111,6 @@ public: */ virtual void bindOptionalUint16(const std::string ¶mName, const optional<uint16_t> ¶mValue) = 0; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - virtual void bindUint32(const std::string ¶mName, const uint32_t paramValue) = 0; - /** * Binds an SQL parameter. * @@ -143,14 +119,6 @@ public: */ virtual void bindOptionalUint32(const std::string ¶mName, const optional<uint32_t> ¶mValue) = 0; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - virtual void bindUint64(const std::string ¶mName, const uint64_t paramValue) = 0; - /** * Binds an SQL parameter. * @@ -159,14 +127,6 @@ public: */ virtual void bindOptionalUint64(const std::string ¶mName, const optional<uint64_t> ¶mValue) = 0; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - virtual void bindDouble(const std::string ¶mName, const double paramValue) = 0; - /** * Binds an SQL parameter. * @@ -175,14 +135,6 @@ public: */ virtual void bindOptionalDouble(const std::string ¶mName, const optional<double> ¶mValue) = 0; - /** - * Binds an SQL parameter. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - void bindBool(const std::string ¶mName, const bool paramValue); - /** * Binds an SQL parameter. * @@ -199,19 +151,7 @@ public: */ virtual void bindBlob(const std::string ¶mName, const std::string ¶mValue) = 0; - /** - * Binds an SQL parameter of type string. - * - * Please note that this method will throw an exception if the string - * parameter is empty. If a null value is to be bound then the - * bindOptionalString() method should be used. - * - * @param paramName The name of the parameter. - * @param paramValue The value to be bound. - */ - virtual void bindString(const std::string ¶mName, const std::string ¶mValue) = 0; - - /** + /** * Binds an SQL parameter of type optional-string. * * Please note that this method will throw an exception if the optional string