From 4d6918b8d7ce2b1e4e699cd30c4fa1af75fffe54 Mon Sep 17 00:00:00 2001 From: Steven Murray <Steven.Murray@cern.ch> Date: Fri, 17 May 2019 20:46:58 +0200 Subject: [PATCH] Added unint-test insert_with_bindUint64_2_pow_54_minus_2 --- rdbms/StmtTest.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/rdbms/StmtTest.cpp b/rdbms/StmtTest.cpp index 7cbccebfb0..59062c9f60 100644 --- a/rdbms/StmtTest.cpp +++ b/rdbms/StmtTest.cpp @@ -138,4 +138,44 @@ TEST_P(cta_rdbms_StmtTest, insert_with_bindUint64) { } } +TEST_P(cta_rdbms_StmtTest, insert_with_bindUint64_2_pow_54_minus_2) { + using namespace cta::rdbms; + + // The MySql support in CTA cannot store an unsigned integer greater than + // 2^54-2 + const uint64_t insertValue = 18014398509481982; + + // Insert a row into the test table + { + const char *const sql = + "INSERT INTO STMT_TEST(" + "UINT64_COL) " + "VALUES(" + ":UINT64_COL)"; + auto stmt = m_conn.createStmt(sql); + stmt.bindUint64(":UINT64_COL", insertValue); + stmt.executeNonQuery(); + } + + // Select the row back from the table + { + const char *const sql = + "SELECT " + "UINT64_COL AS UINT64_COL " + "FROM " + "STMT_TEST"; + auto stmt = m_conn.createStmt(sql); + auto rset = stmt.executeQuery(); + ASSERT_TRUE(rset.next()); + + const auto selectValue = rset.columnOptionalUint64("UINT64_COL"); + + ASSERT_TRUE((bool)selectValue); + + ASSERT_EQ(insertValue,selectValue.value()); + + ASSERT_FALSE(rset.next()); + } +} + } // namespace unitTests -- GitLab